{"action":"created","issue":{"url":"https://api.github.com/repos/gmkurtzer/singularity/issues/119","repository_url":"https://api.github.com/repos/gmkurtzer/singularity","labels_url":"https://api.github.com/repos/gmkurtzer/singularity/issues/119/labels{/name}","comments_url":"https://api.github.com/repos/gmkurtzer/singularity/issues/119/comments","events_url":"https://api.github.com/repos/gmkurtzer/singularity/issues/119/events","html_url":"https://github.com/gmkurtzer/singularity/issues/119","id":164219785,"number":119,"title":"Is it possible to set a $PATH for images from within the image?","user":{"login":"cjprybol","id":3497642,"avatar_url":"https://avatars.githubusercontent.com/u/3497642?v=3","gravatar_id":"","url":"https://api.github.com/users/cjprybol","html_url":"https://github.com/cjprybol","followers_url":"https://api.github.com/users/cjprybol/followers","following_url":"https://api.github.com/users/cjprybol/following{/other_user}","gists_url":"https://api.github.com/users/cjprybol/gists{/gist_id}","starred_url":"https://api.github.com/users/cjprybol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjprybol/subscriptions","organizations_url":"https://api.github.com/users/cjprybol/orgs","repos_url":"https://api.github.com/users/cjprybol/repos","events_url":"https://api.github.com/users/cjprybol/events{/privacy}","received_events_url":"https://api.github.com/users/cjprybol/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gmkurtzer/singularity/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"gmkurtzer","id":13984965,"avatar_url":"https://avatars.githubusercontent.com/u/13984965?v=3","gravatar_id":"","url":"https://api.github.com/users/gmkurtzer","html_url":"https://github.com/gmkurtzer","followers_url":"https://api.github.com/users/gmkurtzer/followers","following_url":"https://api.github.com/users/gmkurtzer/following{/other_user}","gists_url":"https://api.github.com/users/gmkurtzer/gists{/gist_id}","starred_url":"https://api.github.com/users/gmkurtzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmkurtzer/subscriptions","organizations_url":"https://api.github.com/users/gmkurtzer/orgs","repos_url":"https://api.github.com/users/gmkurtzer/repos","events_url":"https://api.github.com/users/gmkurtzer/events{/privacy}","received_events_url":"https://api.github.com/users/gmkurtzer/received_events","type":"User","site_admin":false},"assignees":[{"login":"gmkurtzer","id":13984965,"avatar_url":"https://avatars.githubusercontent.com/u/13984965?v=3","gravatar_id":"","url":"https://api.github.com/users/gmkurtzer","html_url":"https://github.com/gmkurtzer","followers_url":"https://api.github.com/users/gmkurtzer/followers","following_url":"https://api.github.com/users/gmkurtzer/following{/other_user}","gists_url":"https://api.github.com/users/gmkurtzer/gists{/gist_id}","starred_url":"https://api.github.com/users/gmkurtzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmkurtzer/subscriptions","organizations_url":"https://api.github.com/users/gmkurtzer/orgs","repos_url":"https://api.github.com/users/gmkurtzer/repos","events_url":"https://api.github.com/users/gmkurtzer/events{/privacy}","received_events_url":"https://api.github.com/users/gmkurtzer/received_events","type":"User","site_admin":false}],"milestone":null,"comments":14,"created_at":"2016-07-07T03:03:18Z","updated_at":"2016-07-14T18:23:11Z","closed_at":null,"body":"It seems that the $PATH for images is set from within the `singularity/etc/init` file, rather than from within the image itself, and thus is dependent on the host system rather than being portable with the image.\r\n\r\n```bash\r\nvagrant@jessie:~$ sudo singularity --debug shell -w --contain test.img\r\nenabling debugging\r\nending argument loop\r\n+ '[' -f /usr/local/etc/singularity/init ']'\r\n+ . /usr/local/etc/singularity/init\r\n++ unset module\r\n++ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\r\n```\r\n\r\nentering into the shell in the image and editing /etc/profile, ~/.profile, and ~/.bashrc all had no (permanent) effect on the $PATH. I can source them from within the shell session, but it doesn't seem that the /bin/sh dash that is invoked makes any calls to those configuration files upon launching the shell. The easy workaround for this is to just symlink everything to /usr/bin that isn't installed there by default, or call the full path, but is there a way to set a unique $PATH for additional software installation locations within the image itself?\r\n\r\nTwo examples of things I would like to package into images, and where this becomes a problem, are the anaconda distribution of Python and linuxbrew. Both have their own independent /bin folders, and symlinking the executables to the system /bin folders may not be possible due to version conflicts and duplicates between the system /bin folders and the software /bin folders\r\n\r\nan example of what I'm trying to get to work is\r\n```bash\r\nsudo singularity shell -w --contain test.img\r\ncd $HOME\r\napt-get update\r\napt-get install -y wget build-essential\r\nwget http://repo.continuum.io/archive/Anaconda3-4.1.0-Linux-x86_64.sh\r\nbash Anaconda3-4.1.0-Linux-x86_64.sh -b -p $HOME/anaconda3\r\n## modify $PATH to include $HOME/anaconda3/bin\r\nexit\r\n## using full path works\r\nsudo singularity exec -C test.img /root/anaconda3/bin/python\r\n## trying to get this to work\r\nsudo singularity exec -C test.img python\r\n```"},"comment":{"url":"https://api.github.com/repos/gmkurtzer/singularity/issues/comments/232749736","html_url":"https://github.com/gmkurtzer/singularity/issues/119#issuecomment-232749736","issue_url":"https://api.github.com/repos/gmkurtzer/singularity/issues/119","id":232749736,"user":{"login":"gmkurtzer","id":13984965,"avatar_url":"https://avatars.githubusercontent.com/u/13984965?v=3","gravatar_id":"","url":"https://api.github.com/users/gmkurtzer","html_url":"https://github.com/gmkurtzer","followers_url":"https://api.github.com/users/gmkurtzer/followers","following_url":"https://api.github.com/users/gmkurtzer/following{/other_user}","gists_url":"https://api.github.com/users/gmkurtzer/gists{/gist_id}","starred_url":"https://api.github.com/users/gmkurtzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmkurtzer/subscriptions","organizations_url":"https://api.github.com/users/gmkurtzer/orgs","repos_url":"https://api.github.com/users/gmkurtzer/repos","events_url":"https://api.github.com/users/gmkurtzer/events{/privacy}","received_events_url":"https://api.github.com/users/gmkurtzer/received_events","type":"User","site_admin":false},"created_at":"2016-07-14T18:23:11Z","updated_at":"2016-07-14T18:23:11Z","body":"So in the 2.1 testing release I have this implemented as I described above. Now if you want to define a custom environment for your container (a freshly built one) you simply edit the file /environment. \r\n\r\nUnder the hood, there are launching wrapper scripts at /.shell, /.exec and /.run which will all source the /environment file. Hopefully that makes sense.\r\n\r\nAt your next opportunity if you can test it and make sure it works as you would expect it to and let me know that would be fantastic.\r\n\r\nThanks!"}}
{"actor":{"display_login":"gmkurtzer"}}