Mohamed Emad Emsawy
Mohamed Emad Emsawy

Reputation: 43

Webpacker Error While Creating Ruby On Rails App

$ rails 6.0.2 new sample_app2


    .
    .
    .
    Using web-console 4.0.1
    Using webdrivers 4.1.3
    Using webpacker 4.2.2
    Bundle complete! 17 Gemfile dependencies, 75 gems now installed.
    Use `bundle info [gemname]` to see where a bundled gem is installed.
             run  bundle binstubs bundler
    The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
    Skipped bundle since it already exists.
    If you want to overwrite skipped stubs, use --force.
             run  bundle exec spring binstub --all
    * bin/rake: Spring inserted
    * bin/rails: Spring inserted
           rails  webpacker:install
    Traceback (most recent call last):
        4: from /home/emsawy/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `'
        3: from /home/emsawy/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `eval'
        2: from /home/emsawy/.rvm/gems/ruby-2.6.3/bin/yarn:23:in `'
        1: from /home/emsawy/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:400:in `block in replace_bin_path'
    /home/emsawy/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:372:in `block in replace_bin_path': can't find executable yarn for gem yarn. yarn is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
    Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/

Also after performing

 Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/ 

I got the same result

   

     $ yarn -v
     [DEPRECATION] The trollop gem has been renamed to optimist
     and will no longer be supported. Please switch to optimist
     as soon as possible. Yarn v0.1.1 2011 Jesper Kjeldgaard


    $ ruby -v
         ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]


    $ rails -v
         Rails 6.0.2.1

Upvotes: 3

Views: 3308

Answers (2)

user16251777
user16251777

Reputation: 1

Got the same error.

  1. First uninstall yarn by commanding gem uninstall yarn.

    It will ask yn, Enter yn

  2. Next run: command gem update

  3. Finally check yarn --version

Upvotes: 0

nuaky
nuaky

Reputation: 2086

You installed yarn as a gem https://rubygems.org/gems/yarn and this is wrong. Now you should do:

  1. Uninstall this gem, gem uninstall yarn

  2. On mac os brew install yarn if other platform then look here: https://yarnpkg.com/lang/en/docs/install/#debian-stable

  3. Check version, should be something like:

yarn -v

1.21.1

Upvotes: 3

Related Questions