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

build(dev): fix shakpacker config for the webpack-dev-server #2280

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

PiTrem
Copy link
Member

@PiTrem PiTrem commented Jan 10, 2025

Issue

this PR resolve the following issues when starting the wepack-dev-server

  • initialization error:
 failed to load command: bin/shakapacker-dev-server (bin/shakapacker-dev-server)
 ...
 lib/shakapacker/dev_server_runner.rb:57:in `initialize': getaddrinfo: Name or service not known (SocketError)

(to reproduce when using docker-compose.dev.yml comment out the env SHAPACKER_DEV_SERVER_HOST )

  • infinite error :
....
Watchpack Error (watcher): Error: ENOSPC: System limit for number of file watchers reached, watch '.......
Watchpack Error (watcher): Error: ENOSPC: System limit for number of file watchers reached, watch '.......
...

Changes

  • rm erb from shakapacker.yml as it appears to not be interpreted when starting skakapacker dev server and leads to the initialization error.

also rm 'SHAPACKER_DEV_SERVER_HOST' (and .. _PORT) as if it exists, it will anyway have precedence over the value set in the config.

  • rm devServer config from webpack/development.js as the whole block take precedence over the one in shakapacker.yml

  • add watchOptions to ensure node_modules are ignored to avoid the the limit error

@PiTrem PiTrem changed the title build(dev): fix webpacker config build(dev): fix shakpacker config for the webpack-dev-server Jan 10, 2025
@PiTrem PiTrem requested a review from jhmegorei January 10, 2025 10:33
@jhmegorei
Copy link
Collaborator

I'm getting a lot of errors with this when doing a fresh install... gotta see what can be done about them

app-1        | ==> Downloading openssl-1.1.1w.tar.gz...
app-1        | -> curl -q -fL -o openssl-1.1.1w.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8
app-1        |   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
app-1        |                                  Dload  Upload   Total   Spent    Left  Speed
100 9661k  100 9661k    0     0  9433k      0  0:00:01  0:00:01 --:--:-- 9472k
app-1        | ==> Installing openssl-1.1.1w...
app-1        | -> ./config "--prefix=$HOME/.asdf/installs/ruby/2.7.8/openssl" "--openssldir=$HOME/.asdf/installs/ruby/2.7.8/openssl/ssl" --libdir=lib zlib-dynamic no-ssl3 shared
app-1        | -> make -j 12
app-1        |
app-1        | BUILD FAILED (Ubuntu 22.04 on x86_64 using ruby-build 20241225.2)
app-1        |
app-1        | You can inspect the build directory at /tmp/ruby-build.20250110105634.461.7QpcqZ
app-1        | See the full build log at /tmp/ruby-build.20250110105634.461.log
app-1        | >>> check nodejs version as set in package.json: install if mismatch, and correct .tool-versions
app-1        | ./prepare-nodejs.sh: line 14: jq: command not found
app-1        | >>> checking bundler installation
app-1        | ./prepare-rubygems.sh: line 5: gem: command not found
app-1        | >>> Unset bundle config
app-1        | ./prepare-rubygems.sh: line 8: bundle: command not found
app-1        | >>> Installing gems
app-1        | ./prepare-rubygems.sh: line 11: bundle: command not found
app-1        | npm error code EBADENGINE
app-1        | npm error engine Unsupported engine
app-1        | npm error engine Not compatible with your version of node/npm: [email protected]
app-1        | npm error notsup Not compatible with your version of node/npm: [email protected]
app-1        | npm error notsup Required: {"node":"^20.17.0 || >=22.9.0"}
app-1        | npm error notsup Actual:   {"npm":"10.7.0","node":"v18.20.4"}
app-1        |
app-1        | npm error A complete log of this run can be found in: /home/chemotion-dev/.npm/_logs/2025-01-10T10_57_06_778Z-debug-0.log
app-1        | >>> checking yarn installation
app-1        | ./prepare-nodejspkg.sh: line 13: jq: command not found
app-1        |
app-1        | >>> checking for yarn update: required  - current 1.22.22
app-1        |
app-1        | changed 1 package in 2s
app-1        | Reshimming asdf nodejs...
app-1        | >>> Installing JS packages...
app-1        | yarn install v1.22.22
app-1        | [1/5] Validating package.json...
app-1        | [2/5] Resolving packages...
app-1        | success Already up-to-date.
app-1        | $ ./package_postinstall.sh
...
app-1        | ./package_postinstall.sh: line 63:  5199 Broken pipe             tail -n1 "$src"
app-1        |       5200 Illegal instruction     | grep -q "});"
app-1        | Done rewriting import for d3.js in /home/chemotion-dev/app/node_modules/@complat/react-svg-file-zoom-pan/dist/components/svg_wrapper.js
...
app-1        | ================================================
app-1        | Database does not exist, running 'rake db:setup'
app-1        | ================================================
app-1        | ./prepare-ruby-dev.sh: line 32: bundle: command not found
app-1        | ./run-ruby-dev.sh: line 5: bundle: command not found

@PiTrem
Copy link
Member Author

PiTrem commented Jan 10, 2025

@jhmegorei is that the jq thing (#2278 just merged) ?

Copy link

LCOV of commit 196d297 during Continuous Integration #4299

Summary coverage rate:
  lines......: 66.8% (14416 of 21569 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

- rm erb from shakapacker.yml as it appears to not be interpreted when
starting skakapacker dev server

- rm devServer config from webpack/development.js as the whole block take
  precedence over the one in shakapacker.yml

- add watchOptions to ensure  node_modules are ignored
@jhmegorei
Copy link
Collaborator

no that is way before. It's during the installation process. Apparently openssl does not compile successfully, which in turn breaks the ruby installation.

And there is something about the nodejs version, which I haven't looked at yet

app-1        | npm error code EBADENGINE
app-1        | npm error engine Unsupported engine
app-1        | npm error engine Not compatible with your version of node/npm: [email protected]
app-1        | npm error notsup Not compatible with your version of node/npm: [email protected]
app-1        | npm error notsup Required: {"node":"^20.17.0 || >=22.9.0"}
app-1        | npm error notsup Actual:   {"npm":"10.7.0","node":"v18.20.4"}

@PiTrem PiTrem force-pushed the shakapacker_config_upd branch from 196d297 to ef3980b Compare January 10, 2025 11:31
Copy link

LCOV of commit ef3980b during Continuous Integration #4302

Summary coverage rate:
  lines......: 66.8% (14413 of 21564 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@PiTrem PiTrem force-pushed the shakapacker_config_upd branch from 199548b to 9d9e751 Compare January 15, 2025 08:54
Copy link

LCOV of commit 199548b during Continuous Integration #4311

Summary coverage rate:
  lines......: 66.8% (14412 of 21563 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

Copy link

LCOV of commit 9d9e751 during Continuous Integration #4312

Summary coverage rate:
  lines......: 66.8% (14411 of 21564 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@PiTrem PiTrem requested a review from JanCBrammer January 15, 2025 11:54
@PiTrem PiTrem force-pushed the shakapacker_config_upd branch from 9d9e751 to ef3980b Compare January 16, 2025 11:22
@PiTrem
Copy link
Member Author

PiTrem commented Jan 16, 2025

moved 9d9e751 to #2288
as unrelated to the issue

Copy link

LCOV of commit ef3980b during Continuous Integration #4319

Summary coverage rate:
  lines......: 66.8% (14413 of 21564 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

Copy link
Collaborator

@JanCBrammer JanCBrammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I managed to re-build the devcontainer from the current main (b875f69) without the changes in this PR:

  1. Remove everything associated with the devcontainer: docker compose -f docker-compose.dev.yml down --rmi all -v --remove-orphans.
  2. Re-build only app: docker compose -f docker-compose.dev.yml up app.
  3. Once 3. has finished, start the devcontainer as usual.

@PiTrem
Copy link
Member Author

PiTrem commented Jan 17, 2025

it is not happening when using the current docker-compose.dev.yml because SHAPACKER_DEV_SERVER_HOST and SHAPACKER_DEV_SERVER_PORT are set there: it leads to skip reading the corresponding values from shakapacker.yml.
SHAPACKER_DEV_SERVER_PORT are default keys names expected by shakapacker gem to initialize the webpack dev server config.
If one rename those keys it will crash :
gems/shakapacker-8.0.2/lib/shakapacker/dev_server_runner.rb:57:in initialize': service name too long (50) (ArgumentError)

here how to reproduce:

commit 3879fe6e890a85f2846fc00fe0124d1372529477 (HEAD -> how_to_reproduce_2280)
Author: PiTrem <[email protected]>
Date:   Fri Jan 17 15:10:30 2025 +0100

    buggit: show that erb not working in shakapacker.yml
    rename the default env variable
    
    in docker-compose.yml to avoid that shakapacker.rb skips
    settings the host and port with the values from shakapacker.yml

diff --git a/config/shakapacker.yml b/config/shakapacker.yml
index 05d364050..32c485919 100644
--- a/config/shakapacker.yml
+++ b/config/shakapacker.yml
@@ -66,8 +66,8 @@ development:
     # For running dev server with https, set `server: https`.
     # server: https
 
-    host: <%= ENV['SHAPACKER_DEV_SERVER_HOST'] || 'localhost' %>
-    port: <%= ENV['SHAPACKER_DEV_SERVER_PORT'] || 3035 %>
+    host: <%= ENV['MY_SHAPACKER_DEV_SERVER_HOST'] || 'localhost' %>
+    port: <%= ENV['MY_SHAPACKER_DEV_SERVER_PORT'] || 3035 %>
     # Hot Module Replacement updates modules while the application is running without a full reload
     # Used instead of the `hot` key in https://webpack.js.org/configuration/dev-server/#devserverhot
     hmr: true
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index 54e5e8d19..2dadd0c1e 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -32,8 +32,8 @@ services:
       interval: 30s
       timeout: 10s
     environment:
-      - 'SHAKAPACKER_DEV_SERVER_HOST=webpacker'
-      - 'SHAKAPACKER_DEV_SERVER_PORT=3035'
+      - 'MY_SHAKAPACKER_DEV_SERVER_HOST=webpacker'
+      - 'MY_SHAKAPACKER_DEV_SERVER_PORT=3035'
       - 'THOR_SILENCE_DEPRECATION=true'
     ports: # expose default rails port to host machine
       - "3000:3000"
@@ -52,8 +52,8 @@ services:
         condition: service_healthy
     environment:
       - 'NODE_ENV=development'
-      - 'SHAKAPACKER_DEV_SERVER_HOST=webpacker'
-      - 'SHAKAPACKER_DEV_SERVER_PORT=3035'
+      - 'MY_SHAKAPACKER_DEV_SERVER_HOST=webpacker'
+      - 'MY_SHAKAPACKER_DEV_SERVER_PORT=3035'
     env_file: ./.env
     volumes:
       - 'homedir:/home/chemotion-dev/' 

@PiTrem PiTrem merged commit a955344 into main Jan 21, 2025
5 checks passed
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

Successfully merging this pull request may close these issues.

3 participants