{"action":"created","issue":{"url":"https://api.github.com/repos/direnv/direnv/issues/228","repository_url":"https://api.github.com/repos/direnv/direnv","labels_url":"https://api.github.com/repos/direnv/direnv/issues/228/labels{/name}","comments_url":"https://api.github.com/repos/direnv/direnv/issues/228/comments","events_url":"https://api.github.com/repos/direnv/direnv/issues/228/events","html_url":"https://github.com/direnv/direnv/issues/228","id":168887252,"number":228,"title":"Load environment without `cd` into directory","user":{"login":"russellseymour","id":791658,"avatar_url":"https://avatars.githubusercontent.com/u/791658?v=3","gravatar_id":"","url":"https://api.github.com/users/russellseymour","html_url":"https://github.com/russellseymour","followers_url":"https://api.github.com/users/russellseymour/followers","following_url":"https://api.github.com/users/russellseymour/following{/other_user}","gists_url":"https://api.github.com/users/russellseymour/gists{/gist_id}","starred_url":"https://api.github.com/users/russellseymour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/russellseymour/subscriptions","organizations_url":"https://api.github.com/users/russellseymour/orgs","repos_url":"https://api.github.com/users/russellseymour/repos","events_url":"https://api.github.com/users/russellseymour/events{/privacy}","received_events_url":"https://api.github.com/users/russellseymour/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-02T13:38:45Z","updated_at":"2016-08-02T14:35:43Z","closed_at":null,"body":"Is it possible to load up the `direnv` without using `cd` into the directory?\r\n\r\nI am reconfiguring our Jenkins server so that it uses `chruby` and `direnv` to replace `rvm`.  I have got the initial steps of the build writing out the `.envrc` file and `.ruby-version` but it is not being \"activated\".\r\n\r\nIf I SSH onto the machine and `cd` into the workspace then environment activates as expected, but this is an interactive login.\r\n\r\nI understand that Jenkins is not an interactive login which is where I suspect the issues are.  I am trying to use the following script:\r\n\r\n```bash\r\n#!/bin/bash\r\neval \"$(direnv hook bash)\"\r\necho \"2.3.1\" > .ruby-version\r\necho \"use_ruby\" > .envrc\r\ndirenv allow .\r\nwhich ruby\r\n```\r\n\r\nThe `which` always comes back with the rvm version.  I have added the `eval` to the `.bashrc` for the jenkins user and restarted the service but it is not doing what I need it to.\r\n\r\nI am hoping there is a simple command I can run to make this run properly.  Thanks for any advice."},"comment":{"url":"https://api.github.com/repos/direnv/direnv/issues/comments/236923921","html_url":"https://github.com/direnv/direnv/issues/228#issuecomment-236923921","issue_url":"https://api.github.com/repos/direnv/direnv/issues/228","id":236923921,"user":{"login":"russellseymour","id":791658,"avatar_url":"https://avatars.githubusercontent.com/u/791658?v=3","gravatar_id":"","url":"https://api.github.com/users/russellseymour","html_url":"https://github.com/russellseymour","followers_url":"https://api.github.com/users/russellseymour/followers","following_url":"https://api.github.com/users/russellseymour/following{/other_user}","gists_url":"https://api.github.com/users/russellseymour/gists{/gist_id}","starred_url":"https://api.github.com/users/russellseymour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/russellseymour/subscriptions","organizations_url":"https://api.github.com/users/russellseymour/orgs","repos_url":"https://api.github.com/users/russellseymour/repos","events_url":"https://api.github.com/users/russellseymour/events{/privacy}","received_events_url":"https://api.github.com/users/russellseymour/received_events","type":"User","site_admin":false},"created_at":"2016-08-02T14:35:43Z","updated_at":"2016-08-02T14:35:43Z","body":"@zimbatm Thanks for that.  I think there was a clash with RVM which was why the path to the ruby was not correct.\r\n\r\nHowever the reason I wanted to use `direnv` was so that the gems for each project and installed locally in the `.direnv` directory, but this is not happening.\r\n\r\nI have got the `use_ruby` function in the `.direnvrc` for the Jenkins user, but as the build is not an interactive login I assumed that this was not being sourced.  So I copied the `use_ruby` function into the `.envrc` for the project.  But the gems are not being installed in the local dir still.\r\n\r\nThis is the build step I am running\r\n\r\n```bash\r\n#!/bin/bash -ex\r\necho \"2.3.1\" > .ruby-version\r\ncp /home/jenkins/envrc .envrc\r\neval \"$(direnv hook bash)\"\r\ndirenv allow .\r\ngem install bundle\r\n```\r\n\r\nThe `/home/jenkins/envrc` file contains the following:\r\n\r\n```bash\r\n  source /usr/local/share/chruby/chruby.sh\r\n\r\n  local ver=$1\r\n  if [[ -z $ver ]] && [[ -f .ruby-version ]]; then\r\n    ver=$(cat .ruby-version)\r\n  fi\r\n  if [[ -z $ver ]]; then\r\n    echo Unknown ruby version\r\n    exit 1\r\n  fi\r\n\r\n  # switch to the desired ruby\r\n  chruby $ver\r\n\r\n  # Sets the GEM_HOME environment variable to `$PWD/.direnv/ruby/RUBY_VERSION`.\r\n  # This forces the installation of any gems into the project’s sub-folder. If\r\n  # you’re using bundler it will create wrapper programs that can be invoked\r\n  # directly instead of using the `bundle exec` prefix.\r\n  layout_ruby\r\n```\r\n\r\nThe gems are not being installed locally to the project still.  I think that the `layout_ruby` function is not available so the GEM_HOME environment var is not being set.  Where is this function declared?"}}
{"actor":{"display_login":"russellseymour"}}