ruby on rails Importmap::Packager::HTTPError - ruby-on-rails

i want to use javascript npm in rails 7 app but import map throw error every time.
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/importmap-rails-1.1.5/lib/importmap/packager.rb:80:in `handle_failure_response': Unexpected response code (403) (Importmap::Packager::HTTPError)
enter image description here
and my tzinfo-data has error when i what to rails new App, and dont install importmap in new app generate i install it manually

I also had the same issue, after testing it was found that importmap does not have permissions.
Please execute chmod 744 bin/importmap command to see.

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.

Fresh rails 6 app won't deploy on heroku due to 'error Command "webpack" not found'

I just created a new rails 6 app and getting the 'error Command "webpack" not found' message when i try to push to Heroku for the first time. I tried everything:
- regenerating the bins(including webpacker)
- adding nodeJS and Ruby to Heroku
Nothing works, i still get the same error message. Does anyone have any clue? I also want to precise that I've made sure i applied all the solutions presented in the questions looking like mine.
Thanks in advance.
Sounds like you need to run npm install or yarn install on the server.
Whenever a node module like webpack says it "can't be found", this usually means it's not installed yet.

Module build failed: Error: spawn bin/rails ENOENT

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

Rails Error: Unable to access log file. Please ensure that /home.../log/development.log exists and is chmod 0666

Im trying to migrate a db2 database to Ruby on Rails, but just when I run rails g scaffold, I get this:
Rails Error: Unable to access log file. Please ensure that /home/.../log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
I have checked and my development.log does not exist! I'm not sure why, since I followed every step during the installation, but still my file doesn't exist. How can I create it? I have already tried uninstalling and installing Rails again, but the problem remains.
Maybe just do what it asks you to do?:
$ touch the_required_path/development.log
$ chmod 0666 the_required_path/development.log
I've always had success with the the log file permissions as 644. When this has happened to me, more than once I might add, it has always been answered by the question linked below. Since this is the first answer in Google for the query I use, I'm linking to the answer that I really want.
Rails: Unable to access log file

Permission denied - /tmp/.ruby_inline/Inline_ImageScience_cdab.c

I have a Ruby on Rails app that I've recently deployed to a remote server (Ubuntu 9.10, nginx, passenger, ruby-enterprise) and I'm getting the error (works fine locally):
Permission denied - /var/www/project_name/tmp/.ruby_inline/Inline_ImageScience_cdab.c
First, the folder /tmp/.ruby_inline/ is empty - should it be? Is it trying to create Inline_ImageScience_cdab.c or read it?
I think I have all the required gems installed: 'gem list' shows image_science and RubyInline installed. libfreeimage3 and libfreeimage-dev are also installed.
I've run chmod 755 on /tmp/.ruby_inline/ to match the permissions on surrounding folders but I cannot go any higher than that, however, or I get another error:
/var/www/project_name/tmp/.ruby_inline is insecure (40777). It may not be group or world writable. Exiting.
And I guess second, why am I getting this error? :)
Thanks
I was able to fix the problem. The folder /tmp/.ruby_inline/ wasn't supposed to be empty so it wasn't finding Inline_ImageScience_cdab.c and giving a 'permission denied'. The files required were installed to ~/.ruby_inline so I just copied them to /tmp/.ruby_inline and chmod 755 them.
also i guess the filesystem in the production is for some reason read-only to store static content. Contact your host.

Resources