15

When i am creating new rails application i am getting error with webpacker (ArgumentError: Malformed version number string 0.32+git)

Hijas ajmal
  • 151
  • 1
  • 3

7 Answers7

24

I was running into a similar issue running rails 6 on my Docker container. Turns out Rails 6 uses Webpacker, which needs yarn to be installed. Follow steps to install a newer version of Yarn

For Debian make sure these steps are followed

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

and then sudo apt update && sudo apt install yarn

This gave me yarn --version -> 1.19.1

after which sample rails new blog ran successfully, and added blog/config/webpacker.yml (Related to Vanilla Rails 6.0: "error Command "webpack" not found")

It is strange that the documentation does not mention yarn as a dependency.

akotian
  • 3,885
  • 1
  • 33
  • 44
3

I confronted the same issue and resolved by installing yarn using nvm.

npm install -g yarn  

After installing and updating yarn to the current version, I have my Webpacker successfully installed.

Andy Chen
  • 31
  • 1
3

I installed yarn by running sudo apt-get installed yarn on my POP OS(Ubuntu under the hood), and get the same error as yours.

Then, I have fixed this error by following the steps at yarn official page, https://classic.yarnpkg.com/en/docs/install/#debian-stable

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Then, sudo apt-get update

Finally, sudo apt-get install yarn

Fatima
  • 345
  • 1
  • 5
  • 15
2

I should say this error was a step two error, I first had this other highly related problem Vanilla Rails 6.0: "error Command "webpack" not found" and then I was led here.

Here is what I did to solve it. +32 was indeed coming from yarn

$ yarn --version
0.32+git

I tried to find the lucky combination of node/npm/yarn/webpack but I never won anything at the lottery

so I removed yarn...

  • open your package.json in your favorite editor
  • make sure yarn is NOT there
  • delete yarn, or rename the binary
  • rails webpacker:install # now happy
  • rake assets:precompile # also happy
  • rails s # works fine again, I can use ActionCable finally.
Mathieu J.
  • 1,932
  • 19
  • 29
1

npm ls -g

if no list yarn.

sudo npm install -g yarn --force

then

yarn --version

dofstar
  • 11
  • 2
0

If you put 0.32+git as version number please try using a numeric version number, eg: 0.32 (drop the +git)

Andy
  • 104
  • 5
0

Try to update your Yarn version. Webpacker uses Yarn and it probably won't work with an old version, such as "0.32+git". When I updated my version, the problem got solved and I could run the rails application.