Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied when running the executable it installed #100

Closed
DannyBen opened this issue Apr 21, 2020 · 6 comments
Closed

Permission denied when running the executable it installed #100

DannyBen opened this issue Apr 21, 2020 · 6 comments

Comments

@DannyBen
Copy link

Hi.

Running on Ubuntu 18, I get permission denied errors, not sure why.
Here is what I do and what I tested.

$ sudo whalebrew install dannyben/rush
Installed dannyben/rush to /usr/local/bin/rush

$ ls -la /usr/local/bin/rush
-rwxr-xr-x 1 root root 64 Apr 21 18:29 /usr/local/bin/rush

$ cat /usr/local/bin/rush
#!/usr/bin/env whalebrew
image: dannyben/rush
working_dir: /app

$ rush
bash: /usr/local/bin/rush: Permission denied

# and to verify the image is ok
$ docker run --rm -it dannyben/rush --version
0.5.8

I found a couple of duplicate issues, but they were closed and from 2017.

@tjamet
Copy link
Contributor

tjamet commented Oct 16, 2020

Hi! sorry I missed this one.

can I ask you how is whalebrew /usr/local/bin/rush --version working?

@DannyBen
Copy link
Author

DannyBen commented Oct 16, 2020

Same thing. But when running sudo whalebrew, it works.

$ whalebrew /usr/local/bin/rush --version
bash: /usr/local/bin/rush: Permission denied

$ sudo whalebrew /usr/local/bin/rush --version
0.5.8

$ ls -l /usr/local/bin/{whale,rush}*
-rwxr-xr-x 1 root root       64 Oct 16 13:59 /usr/local/bin/rush
-rwxrwxrwx 1 root root 15958371 Oct 16 13:44 /usr/local/bin/whalebrew

Note that I am testing it with whalebrew 0.2.3, since 0.2.4 does not work.

@tjamet
Copy link
Contributor

tjamet commented Oct 16, 2020

ok, I think I understand what is happening
When you run a package, whalebrew will, by default, add the -u $(id -u):$(id -g) fo files are mounted and executed as the standard user.
I am not familiar with rush at all but it looks like it does not support to be run as a different user than the one it is built for in the container.
For this, whalebrew has an option to keep the same user as in the image: LABEL io.whalebrew.config.keep_container_user 'true'
You can also edit your /usr/local/bin/rush and add the option keep_container_user: true in a new line.

in other words, your /usr/local/bin/rush should look like

#!/usr/bin/env whalebrew
image: dannyben/rush
working_dir: /app
keep_container_user: true

This will have the effect to disable the default option to keep the current user ID:

if !p.KeepContainerUser {

@DannyBen
Copy link
Author

I don' understand - why are you modifying container users in the first place?
I thought the entire mandate of whalebrew was to provide alternative to

alias rush="docker run -it --rm dannyben/rush"

If it runs with "docker run..." it should run with whalebrew.

@tjamet
Copy link
Contributor

tjamet commented Oct 18, 2020

The purpose of running as user is to solve the problem of writing to files.
The purpose of whalebrew is to provide a package manager

like Homebrew, but with Docker images

When you install any package on your system, later, when you run the command as any user, you expect the command to be run as your user. Here Whalebrew has, by default, the same behaviour.

A large proportion of the packages actually needs to access and write files on the filesystem, which, in case this flag is not set, issues like #40 or #11 . There are though, as you pointed, some packages for which the user ID they set is important. They are, from my experience, mostly packages that does not need to access the file system. For those, whalebrew has the keep_container_user flag described above.

@DannyBen
Copy link
Author

Thanks. I am closing this.

For my needs, any of the below two approaches is probably more suitable:

alias rush="docker run -it --rm dannyben/rush"

or, to create a file /usr/local/bin/rush

#!/usr/bin/env bash
docker run -it --rm dannyben/rush

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

No branches or pull requests

2 participants