Webpacker: Installing new app Ruby_on_Rails

Created on 7 Feb 2020  路  13Comments  路  Source: rails/webpacker

Screenshot from 2020-02-07 21-15-10
Rails 6.0.2.1
Gem 3.1.2

support

Most helpful comment

@mehdi514 @Pauloparakleto : In my case, it solved by running below commands:

  1. curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
  2. echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  3. sudo apt update && sudo apt install yarn
  4. rails webpacker:install

Hope this helps !!!

All 13 comments

rails aborted! ArgumentError: Malformed version number string 0.32+git /home/muhammad/.rvm/gems/ruby-2.6.3/gems/webpacker-4.2.2/lib/tasks/webpacker/check_yarn.rake:12:inblock (2 levels) in

'
/home/muhammad/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in require' /home/muhammad/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:inblock in require_with_bootsnap_lfi'
/home/muhammad/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in register' /home/muhammad/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:inrequire_with_bootsnap_lfi'
/home/muhammad/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require' /home/muhammad/Desktop/ruby/practice/bin/rails:9:in /home/muhammad/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in load' /home/muhammad/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client/rails.rb:28:incall'
/home/muhammad/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client/command.rb:7:in call' /home/muhammad/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client.rb:30:inrun'
/home/muhammad/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/bin/spring:49:in <top (required)>' /home/muhammad/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/binstub.rb:11:inload'
/home/muhammad/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/binstub.rb:11:in <top (required)>' /home/muhammad/Desktop/ruby/practice/bin/spring:15:inrequire'
/home/muhammad/Desktop/ruby/practice/bin/spring:15:in <top (required)>' bin/rails:3:inload'
bin/rails:3:in <main>' Tasks: TOP => webpacker:install => webpacker:check_yarn (See full trace by running task with --trace)

What does yarn --version give you?

I ran into the same error after installing yarn using their instructions for debian/ubuntu.

The version string I get is:

root@d5ad57c03c3b:/app# yarn --version
0.32+git

Running version 4.2.2 of webpacker.

EDIT:
Seems like the issue was due to the version of node that was installed was old, after updating node and reinstalling yarn the issue went away.

Updated node.js and also tried to install webpacker but still the same error.

What does yarn --version give you?

0.32+git

Thats weird. What does node -v && npm -v && yarn -v give you?

Thats weird. What does node -v && npm -v && yarn -v give you?

v12.16.2
6.14.4
1.22.4

It looks like your yarn version is no longer 0.32+git. You should no longer see that error:

rails aborted! ArgumentError: Malformed version number string 0.32+git

Hi @mehdi514 and @jakeNiemiec,
The first bin webpacker found is not the correct bin (the OS has more the one bin path with the same yarn name), as webpacker code shows. Yesterday I need to fight against this same problem. I saw others issues here when the rails 6 was a beta versions yet. I came to a conclusion that this kind of issue is something normal as yarn versions has been getting old. On that occasion, the solution was found on a classic yarn site. Now, 2020 yarn has changed the way it operates, as shown on this current yarn page. Now it needs to be installed globally (check that yarn page), and then imported to a local project in order to be stable. All I did was following instructions on current yarn page. Then I was able to run rails webpacker:install again.

Hi @mehdi514 and @jakeNiemiec,
The first bin webpacker found is not the correct bin (the OS has more the one bin path with the same yarn name), as webpacker code shows. Yesterday I need to fight against this same problem. I saw others issues here when the rails 6 was a beta versions yet. I came to a conclusion that this kind of issue is something normal as yarn versions has been getting old. On that occasion, the solution was found on a classic yarn site. Now, 2020 yarn has changed the way it operates, as shown on this current yarn page. Now it needs to be installed globally (check that yarn page), and then imported to a local project in order to be stable. All I did was following instructions on current yarn page. Then I was able to run rails webpacker:install again.

thanks @Pauloparakleto for your response. I'll try and let you know.

@mehdi514, yeah I would like to know! If running yarn install --check files fails, just run yarn install without --check files part.

@mehdi514 @Pauloparakleto : In my case, it solved by running below commands:

  1. curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
  2. echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  3. sudo apt update && sudo apt install yarn
  4. rails webpacker:install

Hope this helps !!!

For me with the exact same problem of cmdtest getting installed instead of yarn, the problem was that I copy pasted line 2 from @huzefa-amura 's comment without the "t" of yarn.list. Then when I would run yarn --version, I was getting the version number for cmdtest (0,32+git) instead of a well formed yarn version number.

Was this page helpful?
0 / 5 - 0 ratings