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

Rails default Dockerfile build failed after added bootstrap gem #277

Open
Peredery opened this issue Jan 16, 2024 · 9 comments
Open

Rails default Dockerfile build failed after added bootstrap gem #277

Peredery opened this issue Jan 16, 2024 · 9 comments

Comments

@Peredery
Copy link

  1. Create new project with importmap by default
rails new test_app
cd ../test_app
./bin/bundle add dartsass-rails
./bin/rails dartsass:install
  1. Check if build is ok
    docker build .

Now let's produce error:

  1. add bootstrap gem
    ./bin/bundle add bootstrap --git 'https://github.com/twbs/bootstrap-rubygem'
  2. build it
    docker build .

throw error:

 => ERROR [8/8] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile                                                                 1.3s
------                                                                                                                                         
 > [8/8] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile:                                                                            
1.256 bin/rails aborted!                                                                                                                       
1.256 ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

Installing node/etc is not the right solution because the main reason to use importmap is to drop the nodejs dependency. Any ideas on how to solve this?

@glebm
Copy link
Member

glebm commented Jan 16, 2024

Just like the error message says, you do need some execjs runtime.
The particular runtime is up to you to specify.
E.g. you can use Node or mini_racer.

https://github.com/ai/autoprefixer-rails#usage

@Peredery
Copy link
Author

Just like the error message says, you do need some execjs runtime. The particular runtime is up to you to specify. E.g. you can use Node or mini_racer.

https://github.com/ai/autoprefixer-rails#usage

but what is the point of adding support for dartsass-rails if we are still with "nodejs"? The actual usage with importmaps is broken, we still need to install some js runtime as well

@glebm
Copy link
Member

glebm commented Jan 17, 2024

The Sass engine is orthogonal to autoprefixer. The previous Sass engine didn't use nodejs either (sassc is written in C++), it's autoprefixer that does.

@Peredery
Copy link
Author

The Sass engine is orthogonal to autoprefixer. The previous Sass engine didn't use nodejs either (sassc is written in C++), it's autoprefixer that does.

I see, I didn't know that. But in any case it turns out that there is no sense in flow with importmaps? Why keep nodejs and importmaps together in the project?

@glebm
Copy link
Member

glebm commented Jan 17, 2024

I'm not sure what importmaps have to do with any of this

@jnstq
Copy link

jnstq commented Mar 26, 2024

I've also encountered this issue while trying to build the Dockerfile. Is there a way to make the autoprefixer gem optional?

@Physium
Copy link

Physium commented May 9, 2024

I agree, this makes no sense at all. The whole point of going with the rails default importmap setup was the fact that we do not need to install a js related runtime like node anymore in order to run rails. autoprefixer dependency in bootstraps just defeats that purposes isnt it?

@glebm
Copy link
Member

glebm commented May 10, 2024

I'm considering making the autoprefixer-rails dependency optional in the next release.
Please test #283.

@Physium
Copy link

Physium commented May 10, 2024

@glebm are you able to give a quick run down why autoprefixer-rails as a dependency for bootstrap is required by rails app? so what happens if this is now something optional? I'm still new to this side of rails and just trying to understand how does this work. Greatly appreciate any form of information from you!

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

4 participants