Module build failed: Error: spawn bin/rails ENOENT - ruby-on-rails

After adding the ERB loader and adding the .erb file extension to my application pack (with webpacker), I am getting the following error:
ERROR in ./app/webpack/packs/application.js.erb
Module build failed: Error: spawn bin/rails ENOENT
at _errnoException (util.js:1024:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
# multi (webpack)-dev-server/client?http://localhost:3035 ./app/webpack/packs/application.js.erb
it is also happening with the sample hello_erb.js.erb pack.
Here is an example app that reproduces the problem: https://github.com/jonhue/test_app

You may be missing generated files
If you are missing the bin/rails executable maybe you have cloned from a repository that followed the steps on this issue
Your enviroment should be good to go if you have rails installed correctly and then run:
Rails < 5
$ bundle exec rake rails:update:bin
Rails >= 5
$ rails app:update:bin
You may have issues with webpack installation and/or configuration
If those files on bin\ exists, you may have ran into problems when installing and/or configuring webpack.
Try creating a project installing everything following the documentation, commiting it with a versioning system like GitHub, copy/paste your project configuration and git diff it, I bet you will find differences between them.
You are using Windows or some enviroment that is problematic
If that is the case there is already a discussion to fix it in an open issue in webpacker github. But you could try stuff like using webpacker directly from github to get latest fixes, downgrading to other versions to see if the result is different, or use webpack from source and change the file install.rake that makes you call ./bin/rails app:template... to just rails app:template....

The ERB runner configuration contains a setting that must be changed for it to work on Windows. Open config\webpack\loaders\erb.js and replace this line:
runner: "bin/rails runner"
with this line:
runner: "ruby bin\\rails runner

Related

`yarn storybook` is hanging on `generated-stories-entry.js` for Rails 6 app

I'm adding storybook (v. 6.3.4) to a Rails 6 application and following these instructions I've installed via the CLI (npx sb init) which works fine.
When I run yarn storybook I get the following that hangs (have left if for 1+ hours).
➜ yarn storybook
yarn run v1.22.10
$ start-storybook -p 6006
info #storybook/react v6.3.4
info
info => Loading presets
info => Loading 1 config file in "/Users/rob/Documents/Projects/ProjectName/.storybook"
info => Loading 9 other files in "/Users/rob/Documents/Projects/ProjectName/.storybook"
info => Adding stories defined in "/Users/rob/Documents/Projects/ProjectName/.storybook/main.js"
info => Using prebuilt manager
info => Using implicit CSS loaders
info => Using custom postcss.config.js
info => Using default Webpack4 setup
(node:43594) DeprecationWarning: Relying on the implicit PostCSS loader is deprecated and will be removed in Storybook 7.0.
If you need PostCSS, include '#storybook/addon-postcss' in your '.storybook/main.js' file.
See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-implicit-postcss-loader for details.
(Use `node --trace-deprecation ...` to show where the warning was created)
69% building 2544/2546 modules 2 active ...ects/ProjectName/.storybook/generated-stories-entry.js
In my package.json:
"scripts": {
...
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
yarn build-storybook works fine.
I have tried removing node_modules and running a fresh yarn install
Any thoughts?
For anyone googling this solution, here goes mine.
It seems that a necessary dependency is missing. For example, I needed expo as a dependency in my react-native app. I removed it when I was cleaning up dependencies.
However, in my project, Storybook depended on it. So, that's why it stopped there. No crash, just an infinite load.
To answer Robert's question, I don't know what his problem was (because I'd need to see his package.json file and project). Nevertheless, maybe it is worth trying to find a missing dependency.
This was caused by a couple things for me. I need to:
Use Webpack 5. See docs for updating.
Install babel-plugin-react-require as a dependency
I was finally able to get an error message from the build by doing the following:
Comment out everything from .storybook/main.js that wasn't needed (all addons, plugins, etc).
Remove .storybook/preview.js
At this point, I finally got an error message that babel-plugin-react-require couldn't be found.

Error: `getwd` : No such file or directory - getcwd? [duplicate]

When running rails generate on a new Rails 4.2 project, I keep getting the error:
~/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.0/lib/spring/configuration.rb:37:in `pwd': No such file or directory - getcwd (Errno::ENOENT)
How can I fix this?
The error is caused by an existing Rails Spring process running in the background.
You can easily solve this by running ps ax | grep spring to find the process id and then kill it.
There's an issue on the Rails GitHub about this:
https://github.com/rails/spring/issues/247
This error may also occur if you are working in a directory which was deleted from some other terminal instance.
If the directory (or some sub directory Rails will work with) you are working was renamed or removed, you'll have to run
cd .
and then you can run rails generate [...].
On my machine the same problem was arising because spring server stopped responding.
1:- To restart the spring server type in terminal
$: spring restart
2:- Try running the generator again.

Cucumber command not found

While executing my feature file,in the local Jenkins I am getting the below error.
cucumber: command not found
I am using cucumber feature/xyz.feature command to run the scripts
Any pointers how to proceed.
Normally, you should be able to run the cucumber executable if the setup is done correctly. Read here.
From the error it looks like cucumber is not on your path thus indicating RubyGems binary folder is not on your path. Check the path (use gem env) and update it accordingly.

Ruby 2.0.0-p353, Rails 4.0.2, Netbeans 7.4 - Cannot start webrick

I am trying to use netbeans 7.4 with Ruby 2.0.0-p353 and Rails 4.0.2. Plugin seems to work ok. I am able to generate project and everything is there, but when I try to run project I receive following message and server is not started:
C:\Ruby200-x64\bin\ruby.exe: No such file or directory -- script/rails (LoadError)
There is a comment under official plugin page that says:
I found a simple workaround, I'm using Windows 7 and created a
symbolic link between directories like this: mklink /D script bin
Now I can start and debug my Rails 4 project in Netbeans. Posted by
mgard on Aug 19, 2013
I have tried to do this but it still doesn't solve a problem. Is there anybody that can help?
The proposed solution works well from what I have seen. What is the error you are getting? Are you able to create directory link? You would need Admin rights for that and should start the command prompt "Run as Administrator". Alternatively, try right-clicking on the "bin" directory and execute "Create shortcut" that must be renamed to "script" later.
I'm using Aptana on Win 8 and came to the problem.
Now rails 4 doesn't have script/rails in the folder. We will need to create it manually in your application folder. You can simply create the folder, then mklink or copy the file in the script folder. Please take caution that your IDE will have proper access to the file you create, otherwise, you will come to the error:
c:\Ruby200\bin\rubyw.EXE: No such file or directory -- C:/Users/Zhou/Documents/GitHub/HR-SNA/script/rails (LoadError)
Go to project's root directory and execute from a console following command:
ln -s ./bin ./script
In Rails 4, script has been replaced with bin

generating WAR file for ruby on rails application

I am using Warbler to generate a WAR file for my ruby on rails application. I don't use anything special in my application, and i only run the "warble war" command.
In the WAR generation i am getting those 2 warnings
warning: skipping minitest
warning: skipping json
Upon the importing of the WAR in eclipse, the project can't be built and it says
Archive for required library: '/WebContent/WEB-INF/lib/gems-gems-warbler-1.4.1-spec-sample_war-some.jar'cannot be read or is not a valid ZIP file
I tried to follow some workarounds from https://github.com/jruby/warbler/issues/199 but without any clue. I am using Rails version 4.0.2 and warbler version 1.4.1 .I am new to deployment so i would be grateful if somebody can help me. Thanks
A better way to exclude the offending file : the warble config.
Generate the configuration with
warble config
Then uncomment the following line to fix it :
config.gem_excludes = [/^(test|spec)\//]
Let me warn you that this is a complete butcher job and I only used this because I was perplexed as to why I was also getting the same errors and Tomcat died when trying to deploy my jruby/rails application. Here's what I did:
$ ls -l /usr/local/opt/tomcat/libexec/webapps/workspace/WEB-INF/lib/*sample*
You will see some warbler sample jars there. gems-gems-warbler-1.4.1-spec-sample_war-some.jar has a size of 0. It's the problem, but I figure I don't really need any sample jars, thank you. So:
$ bundle show warbler
/PATH/.rvm/gems/jruby-1.7.10#rails4/gems/warbler-1.4.1
$ rm -rf /PATH/.rvm/gems/jruby-1.7.10#rails4/gems/warbler-1.4.1/spec/*sample*
$ bundle exec warble war
Deploy to Tomcat, and the context starts just fine. Less than ideal and probably there is a "correct" solution. This got me moving forward, tho.

Resources