Webpacker Error on creating new rails app in rails 6 - ruby-on-rails

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

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.

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.

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

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.

npm ls -g
if no list yarn.
sudo npm install -g yarn --force
then
yarn --version

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

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.

Related

Yarn Unknown Syntax Error: Unsupported option name ("--check-files")

When I try to run yarn install --check-files on a rails repo that I cloned I'm getting the following error:
Unknown Syntax Error: Unsupported option name ("--check-files").
$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds] [--mode #0]
I've tried updating yarn and node to the latest stable versions
I've tried deleting yarn/node modules and yarn.lock in the local folder and running yarn install again
I've tried yarn upgrade --latest which also brings up a similar error Usage Error: Couldn't find a script named "upgrade".
I'm currently using volta to manage my versions and have not had too much trouble up until now.
I've previously run --check-files on other repos with no problems.
Ok turns out my system was running yarn 3.* globally which was conflicting with my rails version (6.0.5). I had originally installed yarn using brew so I had to uninstall and start again with npm using the following steps:
brew uninstall yarn to remove yarn with brew
npm install -g yarn to install yarn with npm
yarn set version classic to set yarn version to 1.*
yarn -v to make sure I was on version 1.*

Yarn packages won't update for dependency issue

On a development server, for an application barely deployed, rails commands won't execute because of lack of integrity file.
error Couldn't find an integrity file
error Found 1 errors.
========================================
Your Yarn packages are out of date!
Please run `yarn install --check-files` to update.
========================================
Both
yarn install --check-files
yarn install
lead to the same error
compression-webpack-plugin#4.0.1: The engine "node" is incompatible with this module. Expected version ">= 10.13.0". Got "8.17.0"
Found incompatible module
Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
The 'visit' prompt is unfortunately of no use, as it does not deal with the node engine.
Being barely deployed, there is no node-modules directory yet, which is expected. However on development machine there is the directory and no issues whatseoever in precompiling assets.
Server context:
node -v
> v8.17.0
How can this situation be unblocked?
you need to update the node to a version higher than the one mentioned >= 10.13.0 then re-install yarn and re-run the check:
if you're on Mac OS:
brew install node#14 && brew link --force node#14
brew install yarn
if you're on Linux:
cd ~
curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
then check if you have a compatible version
node -v
=> v14.2.0
``
if so re-run any of your commands:
```bash
yarn install --check-files
yarn install

''rvm requirements'" is failing because of apt-get... WUT

I just want to install Ruby-on-Rails on ubuntu 14.04 LTS 64 bit running inside VMWare in a Windows 8 environment.
I am following the following steps:
1. Install RVM multi-user
\curl -L https://get.rvm.io | sudo bash -s stable
adduser yourusername rvm
rvm requirements
install the requirements given
log out and back in
add source command to ~/.bash.rc
2. Install ruby and rails and others
rvm install 1.9.3
rvm rubygems current
gem install rails
sudo apt-get install nodejs
3. Does rails work?
cd ~
mkdir rails
cd rails
START DEVELOPING!
useful commands:
bundle install -- install the gems needed for this app
bundle exec rails server -- run the server!
sudo apt-get install nodejs
but on the 3rd step I get the following:
mattnificent#UbuntuVMWare:~$ rvm requirements
Checking requirements for ubuntu.
Installing requirements for ubuntu.
Updating system.................
Error running 'requirements_debian_update_system ',
showing last 15 lines of /home/mattnificent/.rvm/log/1410125635/update_system.log
+ case "${TERM:-dumb}" in
+ case "$1" in
+ [[ -t 2 ]]
+ return 1
+ printf %b 'There has been error while updating '\''apt-get'\'', please give it some time and try again later.
For 404 errors check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
\n'
There has been error while updating 'apt-get', please give it some time and try again later.
For 404 errors check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
+ return 100
Requirements installation failed with status: 100.
Can anyone tell me what the hell is going on?
ELI5.
Thanks.

Can't install Ruby on Rails with RVM on Ubuntu 13.04

I am trying to install RVM on my Ubuntu machine.
I have used curl to get RVM, but some RVM commands (install, requirements) throw this apt-get error:
There has been error while updating 'apt-get', please give it some time and try again later.
For 404 errors check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
type rvm | head -1 returns
rvm is a function
-bash: type: write error: Broken pipe
which gem
/usr/bin/gem
I have checked the "Run command as a login shell" option
Steps followed from this tutorial:
sudo apt-get install curl
curl -L get.rvm.io | bash -s stable --auto
. ~/.bash_profile
rvm requirements - doesn't work properly
I have also looked at the official RVM documentation, but it seems to be very similar.
Any ideas?
UPDATE: I managed to do it. I disabled all the third party ppa URLs and it installed smoothly.
There are some important packages your system needs before install rvm. Run at the terminal:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev \
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev \
sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake \
libtool bison subversion nodejs
Then install rvm with:
curl -L https://get.rvm.io | bash -s stable --ruby
Now you need to put a setting in your .bashrc to add rvm to PATH for scripting. Run:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
Open a new terminal and test rvm.
run
sudo apt-get update
sudo apt-get install build-essential
and then try again.
Hye Guys!!
I got the solution. Actually error is because the information we need for installation is not available at sever define for software & update. I change it to from my local "Server from India" (In my case) to "Main Server".
It's working perfectly for me now :)
I was having the same problem with my install, and then I fully read the details that terminal left once the install was finished.
Try using source /usr/local/rvm/scripts/rvm
Once I did that, the function type rvm | head -1 returned rvm is a function
In my Case i fixed the error by:
rvmsudo rvm install 1.9.3
rvm --default 1.9.3
rvmsudo rvm remove 1.9.3
rvm install 1.9.3
Source
Try disabling repository which appear at 404 sudo apt-get update or viewing logs rvm. The fact is that when you install rvm is trying to update a list of your packages and if you have 404 to go to bed =)
\curl -L https://get.rvm.io | bash -s stable --ruby .
paste this in your terminal window.I used this.It worked for me.for RVM for ruby
\curl -L https://get.rvm.io | bash -s stable --rails .
Use these to install RVM with ruby on rails
For people that know nothing about Linux or are newbies to Linux (like me) those are steps how to solve this (explanation, that was given above, was not that clear for me :) ).
Go to Package Manager, tab Settings, Preferences
In the opened window you'll see Other Software tab or something like that with links to servers. In my case one of these (it's mentioned in the error log that was produced by rvm) was causing errors and was not available (404 errors). I just unchecked it.
run rmv dependencies only when you closed Package Manager, or you'll get error saying that something is locked at the moment.
And everything now is installed successfully! :)
The most common symptom of this problem occurs (as seth2810 hinted at) with non-zero exit codes from an apt-get update command, which rvm requirements expects. You should run this command yourself (with sudo) and check for any problems.
If you have 404s in the output, check that the package sources for the bad URLs are still correct/current. You can remove package sources more easily with sudo apt-get install software-properties-common, followed by sudo add-apt-repository --remove {URL_OF_PROBLEM_PACKAGE_SOURCE} for each failed url.
If you have something hinting at packages with 'unmet dependencies', try sudo apt-get -f install. This command attempts to fix incomplete installs by fetching missing packages and works most of the time. Otherwise... by this point you probably have a more specific error to google for anyway!

How can I uninstall Ruby on ubuntu?

How can I uninstall Ruby 1.9.2dev (2010-07-02) [i486-linux]
on ubuntu?
Need to reinstall - please help
Run the following command from your terminal:
sudo apt-get purge ruby
Usually works well for me.
(caution: this can delete essential system files related to GRUB and other components)
This command should do the trick (provided that you installed it using a dpkg-based packet manager):
aptitude purge ruby
At first find out where ruby is?
then
rm -rf /usr/local/lib/ruby
rm -rf /usr/lib/ruby
rm -f /usr/local/bin/ruby
rm -f /usr/bin/ruby
rm -f /usr/local/bin/irb
rm -f /usr/bin/irb
rm -f /usr/local/bin/gem
rm -f /usr/bin/gem
I have tried many include sudo apt-get purge ruby , sudo apt-get remove ruby and sudo aptitude purge ruby, both with and without '*' at the end. But none of them worked, it may be I've installed more than one version of ruby.
Finally, when I tried sudo apt-get purge ruby1.9(with the version), then it works.
Run the following command on the terminal:
sudo apt-get autoremove ruby
Here is what sudo apt-get purge ruby* removed relating to GRUB for me:
grub-pc
grub-gfxpayload-lists
grub2-common
grub-pc-bin
grub-common
On Lubuntu, I just tried apt-get purge ruby* and as well as removing ruby, it looks like this command tried to remove various things to do with GRUB, which is a bit worrying for next time I want to reboot my computer. I can't yet say if any damage has really been done.
If you used rbenv to install it, you can use
rbenv versions
to see which versions you have installed.
Then, use the uninstall command:
rbenv uninstall [-f|--force] <version>
for example:
rbenv uninstall 2.4.0 # Uninstall Ruby 2.4.0
If you installed Rails, it will be removed, too.
Why you are removing old version of the ruby?
rvm install 2.4.2 // version of ruby u need to insatll
rvm use 2.4.2 --default // set ruby version you want use by default
Using rvm you can install multiple ruby version in the system
Please follow below steps install ruby using rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.4.2
rvm use 2.4.2 --default
ruby -v
The installation step will change for different Ubuntu version
For more info,
https://gorails.com/setup/ubuntu/14.04
You can use sudo apt remove ruby
Uninstall the make install software when make uninstall invalid.
make install will create file '.installed.list'
Choose to clean up the files described in .installed.list (need to be careful if you have multiple versions)
Case: ruby2.4 switch to ruby2.3, thinking directly delete all ruby software, and then re-make install 2.3, see: Ruby # Installation Guide
make install -> .installed.list
see .installed.list file, delete all install files.
‌
rm -rf /usr/local/include/ruby-*
rm -rf /usr/local/lib/ruby
rm /usr/local/bin/erb /usr/local/bin/gem /usr/local/bin/irb /usr/local/bin/rdoc /usr/local/bin/ri /usr/local/bin/ruby
rm /usr/local/share/man/man1/erb.1 /usr/local/share/man/man1/irb.1 /usr/local/share/man/man1/ri.1 /usr/local/share/man/man1/ruby.1
rm /usr/local/lib/libruby-static.a
rm -rf /usr/local/lib/pkgconfig/ruby-*
which ruby
pkg-config --list-all|grep ruby

Resources