Node/python failures when deploying my Rails app?

So I’m running fly deploy --remote-only, trying to deploy my Rails app for the first time. My Dockerfile is straight out of the box, except I tweaked the RUBY_VERSION. For some reason I’m seeing this error which seemingly has to do with node and python.

 => ERROR [node_modules 3/3] RUN if [ -f "yarn.lock" ]; then     yarn install;     elif [ -f "package-lock.json" ]; then     npm install;     else     mkdir node_modules;     fi               16.7s
------                                                                                                                                                                                                
 > [node_modules 3/3] RUN if [ -f "yarn.lock" ]; then     yarn install;     elif [ -f "package-lock.json" ]; then     npm install;     else     mkdir node_modules;     fi:                           
#20 0.607 yarn install v1.22.19                                                                                                                                                                       
#20 0.685 [1/4] Resolving packages...                                                                                                                                                                 
#20 1.089 [2/4] Fetching packages...                                                                                                                                                                  
#20 12.09 [3/4] Linking dependencies...                                                                                                                                                               
#20 12.10 warning " > webpack-dev-server@3.10.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".                                                                                                
#20 12.10 warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0".                                                                                     
#20 15.11 [4/4] Building fresh packages...                                                                                                                                                            
#20 16.21 error /app/node_modules/node-sass: Command failed.                                                                                                                                          
#20 16.21 Exit code: 1                                                                                                                                                                                
#20 16.21 Command: node scripts/build.js                                                                                                                                                              
#20 16.21 Arguments: 
#20 16.21 Directory: /app/node_modules/node-sass
#20 16.21 Output:
#20 16.21 Building: /root/.volta/tools/image/node/14.20.0/bin/node /app/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
#20 16.21 gyp info it worked if it ends with ok
#20 16.21 gyp verb cli [
#20 16.21 gyp verb cli   '/root/.volta/tools/image/node/14.20.0/bin/node',
#20 16.21 gyp verb cli   '/app/node_modules/node-gyp/bin/node-gyp.js',
#20 16.21 gyp verb cli   'rebuild',
#20 16.21 gyp verb cli   '--verbose',
#20 16.21 gyp verb cli   '--libsass_ext=',
#20 16.21 gyp verb cli   '--libsass_cflags=',
#20 16.21 gyp verb cli   '--libsass_ldflags=',
#20 16.21 gyp verb cli   '--libsass_library='
#20 16.21 gyp verb cli ]
#20 16.21 gyp info using node-gyp@3.8.0
#20 16.21 gyp info using node@14.20.0 | linux | x64
#20 16.21 gyp verb command rebuild []
#20 16.21 gyp verb command clean []
#20 16.21 gyp verb clean removing "build" directory
#20 16.21 gyp verb command configure []
#20 16.21 gyp verb check python checking for Python executable "python2" in the PATH
#20 16.21 gyp verb `which` failed Error: not found: python2
#20 16.21 gyp verb `which` failed     at getNotFoundError (/app/node_modules/which/which.js:13:12)
#20 16.21 gyp verb `which` failed     at F (/app/node_modules/which/which.js:68:19)
#20 16.21 gyp verb `which` failed     at E (/app/node_modules/which/which.js:80:29)
#20 16.21 gyp verb `which` failed     at /app/node_modules/which/which.js:89:16
#20 16.21 gyp verb `which` failed     at /app/node_modules/isexe/index.js:42:5
#20 16.21 gyp verb `which` failed     at /app/node_modules/isexe/mode.js:8:5
#20 16.21 gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21)
#20 16.21 gyp verb `which` failed  python2 Error: not found: python2
#20 16.21 gyp verb `which` failed     at getNotFoundError (/app/node_modules/which/which.js:13:12)
#20 16.21 gyp verb `which` failed     at F (/app/node_modules/which/which.js:68:19)
#20 16.21 gyp verb `which` failed     at E (/app/node_modules/which/which.js:80:29)
#20 16.21 gyp verb `which` failed     at /app/node_modules/which/which.js:89:16
#20 16.21 gyp verb `which` failed     at /app/node_modules/isexe/index.js:42:5
#20 16.21 gyp verb `which` failed     at /app/node_modules/isexe/mode.js:8:5
#20 16.21 gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21) {
#20 16.21 gyp verb `which` failed   code: 'ENOENT'
#20 16.21 gyp verb `which` failed }
#20 16.21 gyp verb check python checking for Python executable "python" in the PATH
#20 16.21 gyp verb `which` failed Error: not found: python
#20 16.21 gyp verb `which` failed     at getNotFoundError (/app/node_modules/which/which.js:13:12)
#20 16.21 gyp verb `which` failed     at F (/app/node_modules/which/which.js:68:19)
#20 16.21 gyp verb `which` failed     at E (/app/node_modules/which/which.js:80:29)
#20 16.21 gyp verb `which` failed     at /app/node_modules/which/which.js:89:16
#20 16.21 gyp verb `which` failed     at /app/node_modules/isexe/index.js:42:5
#20 16.21 gyp verb `which` failed     at /app/node_modules/isexe/mode.js:8:5
#20 16.21 gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21)
#20 16.21 gyp verb `which` failed  python Error: not found: python
#20 16.21 gyp verb `which` failed     at getNotFoundError (/app/node_modules/which/which.js:13:12)
#20 16.21 gyp verb `which` failed     at F (/app/node_modules/which/which.js:68:19)
#20 16.21 gyp verb `which` failed     at E (/app/node_modules/which/which.js:80:29)
#20 16.21 gyp verb `which` failed     at /app/node_modules/which/which.js:89:16
#20 16.21 gyp verb `which` failed     at /app/node_modules/isexe/index.js:42:5
#20 16.21 gyp verb `which` failed     at /app/node_modules/isexe/mode.js:8:5
#20 16.21 gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21) {
#20 16.21 gyp verb `which` failed   code: 'ENOENT'
#20 16.21 gyp verb `which` failed }
#20 16.21 gyp ERR! configure error 
#20 16.21 gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
#20 16.21 gyp ERR! stack     at PythonFinder.failNoPython (/app/node_modules/node-gyp/lib/configure.js:484:19)
#20 16.21 gyp ERR! stack     at PythonFinder.<anonymous> (/app/node_modules/node-gyp/lib/configure.js:406:16)
#20 16.21 gyp ERR! stack     at F (/app/node_modules/which/which.js:68:16)
#20 16.21 gyp ERR! stack     at E (/app/node_modules/which/which.js:80:29)
#20 16.21 gyp ERR! stack     at /app/node_modules/which/which.js:89:16
#20 16.21 gyp ERR! stack     at /app/node_modules/isexe/index.js:42:5
#20 16.21 gyp ERR! stack     at /app/node_modules/isexe/mode.js:8:5
#20 16.21 gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:192:21)
#20 16.21 gyp ERR! System Linux 5.12.2
#20 16.21 gyp ERR! command "/root/.volta/tools/image/node/14.20.0/bin/node" "/app/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
#20 16.21 gyp ERR! cwd /app/node_modules/node-sass
#20 16.21 gyp ERR! node -v v14.20.0
#20 16.21 gyp ERR! node-gyp -v v3.8.0
#20 16.21 gyp ERR! not ok 
#20 16.21 Build failed with error code: 1
#20 16.21 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/bash -c if [ -f "yarn.lock" ]; then     yarn install;     elif [ -f "package-lock.json" ]; then     npm install;     else     mkdir node_modules;     fi]: exit code: 1

Huh? I’m confused why there is any dependency on node or python.

I honestly don’t know Docker very well, but tried commenting out the following block in the Dockerfile to see what would happen:

FROM build_deps as node_modules

COPY package*json ./
COPY yarn.* ./

RUN if [ -f "yarn.lock" ]; then \
    yarn install; \
    elif [ -f "package-lock.json" ]; then \
    npm install; \
    else \
    mkdir node_modules; \
    fi

Now, fly deploy --remote-only errors with

 > FROM docker.io/library/node_modules:latest:
------
Error failed to fetch an image or build from source: error building: failed to load cache key: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

which I’m also struggling to make sense of.

What’s going on here? Sorry if this is a noob question; I really don’t know much about Node or Docker, just wanted to run a plain old rails app.

This isn’t a complete answer but Rails 6 adopted webpack and that drags Node.js into the mix so unless you pull out webpack and go the modern Rails 7 option of ditching all the JS dependencies, you’ll need to have Node.js’s build complete successfully as part of the build. It appears Node has installed successfully for you, but node-gyp requires Python, and that appears to be failing.

It’s a long shot, but I would be adding something higher up your Dockerfile to install Python. How you do that varies on what Linux distro you’re using. If Alpine, then something like RUN apk add python3 make g++ prior to the Node stuff. If anything else, you’ll need to get Googling :slight_smile:

1 Like

OK, thanks again, that makes sense. It looks like the build worker is running Debian 10, which should come with python already installed. I will continue poking around and Googling, but I’m pretty surprised that the out-of-the-box configs are so broken.

Where is this Dockerfile originally from BTW?

It was automatically generated when I first ran flyctl launch in my rails repo.