Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

#requires_sudo? logic with read-only files #3092

Closed
pmahoney opened this issue Jul 11, 2014 · 4 comments
Closed

#requires_sudo? logic with read-only files #3092

pmahoney opened this issue Jul 11, 2014 · 4 comments

Comments

@pmahoney
Copy link
Contributor

I install gems into a user-writeable directory. Then I make this directory read-only for running my app (*). This trips up #requires_sudo?, which assumes sudo is required, and later the wrong path for git sources is used: git.rb:83.

When I run bundle show, I get the error:

git@some-gem (at master) is not yet checked out. Run `bundle install` first.

(though if I remove sudo from $PATH, or otherwise change the logic of #requires_sudo?, everything works fine.)

I'm not sure what I'd expect bundler to do in the ideal case. There are many times I want to use bundle exec or require bundler/setup at a point where I actively do not want bundler to be installing anything, so it doesn't make sense to perform the "sudo" test. However I see that if gems were installed into user_bundler_path, then the "sudo" test would be needed to find them at runtime.

(*) I'm experimenting with ways to manage gems with nix package manager, but that should be irrelevant in this case, though it makes its packages' files read-only.

@indirect
Copy link
Member

IIRC, git gems need to be writable. I believe (although I haven't checked) that it would be okay to do non-install commands like bundle exec for Gemfiles that don't contain git gems when the other gems are read only. That might be possible to allow without any big changes.

On Thu, Jul 10, 2014 at 7:15 PM, pmahoney [email protected]
wrote:

I install gems into a user-writeable directory. Then I make this directory read-only for running my app (*). This trips up #requires_sudo?, which assumes sudo is required, and later the wrong path for git sources is used: git.rb:83.
When I run bundle show, I get the error:

git@some-gem (at master) is not yet checked out. Run `bundle install` first.

(though if I remove sudo from $PATH, or otherwise change the logic of #requires_sudo?, everything works fine.)
I'm not sure what I'd expect bundler to do in the ideal case. There are many times I want to use bundle exec or require bundler/setup at a point where I actively do not want bundler to be installing anything, so it doesn't make sense to perform the "sudo" test. However I see that if gems were installed into user_bundler_path, then the "sudo" test would be needed to find them at runtime.

(*) I'm experimenting with ways to manage gems with nix package manager, but that should be irrelevant in this case, though it makes its packages' files read-only.

Reply to this email directly or view it on GitHub:
#3092

@pmahoney
Copy link
Contributor Author

Can you clarify what you mean by "git gems need to be writeable"? Do you mean at run-time ("bundle exec") as opposed to install-time? I've not thoroughly tested things, but I am definitely able to run several good sized Rails apps with read-only gems and read-only git gems.

I've been thinking about this a bit more. I see (in git.rb) the #install_path method performs the sudo test, and #path is just an alias for #install_path. What would you think about removing the alias and having the #path method test for existence (if the directory exists, then there's no need to use a different path) before falling back to #install_path? I'll code something like that up and see how it works. (Thus #path handles run-time stuff and #install_path handles install-time).

@indirect
Copy link
Member

That seems like a reasonable approach to me.

On Jul 11, 2014, at 8:53 PM, pmahoney [email protected] wrote:

Can you clarify what you mean by "git gems need to be writeable"? Do you mean at run-time ("bundle exec") as opposed to install-time? I've not thoroughly tested things, but I am definitely able to run several good sized Rails apps with read-only gems and read-only git gems.

I've been thinking about this a bit more. I see (in git.rb) the #install_path method performs the sudo test, and #path is just an alias for #install_path. What would you think about removing the alias and having the #path method test for existence (if the directory exists, then there's no need to use a different path) before falling back to #install_path? I'll code something like that up and see how it works. (Thus #path handles run-time stuff and #install_path handles install-time).


Reply to this email directly or view it on GitHub.

@pmahoney
Copy link
Contributor Author

Best I could do: #3097

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants