SamEureka / balenaCodeServer

balenaCodeServer is a free Visual Studio Code based IDE that runs in your browser, served from your Raspberry Pi!
10 stars 5 forks source link

Npm error installing balena-cli #9

Closed javiercp closed 2 years ago

javiercp commented 2 years ago

Hi!!

First of all thanks for creating this project. I'm learning a lot checking it.

I've tried to deploy it to my Raspberry4, using the "Deploy with Balena" button and I'm getting an error that should not happen.

E86F6F0D-7F93-4840-8B67-D8463AAC6DBF

Npm should be installed in Linuxserver container, right? Or do I need to add it in the Dockerfile.template like this?

RUN apt-get update && apt-get install -y make g++ gh npm

Cheers :)

javiercp commented 2 years ago

Hello,

In case this helps, this is what I had to change in the Dockerfile.template to get the balena-cli installed in my environment:

# Base Image
FROM lscr.io/linuxserver/code-server

# Install the repo cert and install gh with some dependencies required by Balena CLI 
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
RUN apt-get update && apt-get install -y make g++ gh python3

# Build/install balena-cli (ARM method)
RUN touch ~/.bashrc && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
RUN . ~/.bashrc && nvm install 12 && npm install balena-cli --global --production --unsafe-perm

I'm not sure if it is the best solution, but it seems to work.

Cheers :)

SamEureka commented 2 years ago

Hello!

Thanks for putting in an issue. I don't know why this error is happening. node/npm is already installed in the lscr.io as you mention. I never got this error in my testing. I did get a WARN in the logs saying the version wasn't in the supported range. But it still built. I see that you have a fork with the nvm install before the balena-cli install. Any luck? I'd be happy to merge a pull request it you get it solved. I'm going to try and recreate the error on my side.

//Sam

I sent this before I saw your message!

SamEureka commented 2 years ago

Javi,

I had the exact same code RUN . ~/.bashrc && nvm install 12 && npm install balena-cli --global --production --unsafe-perm in a previous iteration but couldn't get the nvm install to persist for the non-root user abc that the container uses. So I scrapped the code. This is a good solution if it is working!

Would you mind submitting a pull request? I'd like for you to get credit for the fix.

Thanks! //Sam

SamEureka commented 2 years ago

Getting failed builds with both methods now 💣 💥

RUN . ~/.bashrc && nvm install 12 && npm install balena-cli --global --production --unsafe-perm throws this err on build ->

[code-server]  npm ERR!
[code-server]   gyp ERR! node-gyp -v v8.4.1
[code-server]  npm ERR!
[code-server]   gyp ERR! not ok

going to try it with --lts

javiercp commented 2 years ago

Hi Sam,

I could build it, but I've only been able to make it work in bash.

I haven't used zsh, but when I tried using another programming oriented shell (fish) in my desktop some parts of scripts didn't work out of the box.

If you get it to build and it doesn't seem to work with the user abc, try to open a bash shell.

Cheers :)

SamEureka commented 2 years ago

@javiercp Thanks again for the issue! I hacked together some code to get the Build With Balena button working again. It's working in bash but zsh needs some work. I'm going to explore configuring zsh with an s6-overlay in /etc/cont-init.d. Just need to understand how they work!

//Sam