softprops / lambda-rust

🐳 🦀 a dockerized lambda build env for rust applications
MIT License
162 stars 76 forks source link

Fails with /usr/local/bin/build.sh: line 35: //.cargo/env: No such file or directory #84

Open smirnoal opened 3 years ago

smirnoal commented 3 years ago

it may be a bug in Rust installer, but build.sh fails with error

% docker run --rm \     
    -u $(id -u):$(id -g) \
    -v ${PWD}:/code \
    -v ${HOME}/.cargo/registry:/cargo/registry \
    -v ${HOME}/.cargo/git:/cargo/git \
    softprops/lambda-rust
/usr/local/bin/build.sh: line 35: //.cargo/env: No such file or directory
ggomagundan commented 3 years ago

I have this issue too

snydergd commented 3 years ago

I have this issue as well. If I run the container without a different/non-root uid, it works fine (uses /root/.cargo/env).

Running OSX Big Sur with Docker installed through the homebrew cask.

$HOME appears to come through as / for me (thus, the error on line 53 -- . $HOME/.cargo/env). My uid/gid are 501/20.

find / -iname .cargo in the container as root only turns up that one in /root/.cargo.

That script appears to be the entrypoint, and nothing in it seems to be installing cargo or setting up a .cargo directory (imagine it's probably part of the build). I don't think there's any chance the script could skip line 53, either.

As a workaround, you could probably add an additional volume for /.cargo/ with the necessary env file in it, but that's a lot of work and you'd have to figure out what to put in that file. Or if you trust it, I suppose you could run as root. As mentioned, the ownership/permissions might get a little wonky when you build, but you could change them back with chown.

alisonjenkins commented 3 years ago

I also just hit this issue but was able to resolve it by building the container from master.

Try cloning the repo and just running make build in the root of the repo. Annoyingly this means that the fix will only apply to your local docker install so won't help if you are using CICD. For that case you will need to push to a container registry and use your repository until a fixed build is pushed to the softprops repo.

RaviH commented 3 years ago

Hello, any update on this? While we can build it locally as @alanjjenkins mentioned above, it would be great if we didn't have to do this intermediary step. Thanks!

encee commented 3 years ago

Any update on this? Thanks!

amritabithi commented 2 years ago

To fix this, run the following command to open /home//.bashrc : gedit ~/.bashrc

And just delete the line that will say something like: . "$HOME/.cargo/env"

Save the file and open a new terminal and you should no longer see the error.