yarn uninitialized constant Socket::SOL_TCP - ruby

I'm trying to use yarn here and got into a problem that might be related to ruby.
On executing any yarn command, I get the error .../.rvm/gems/ruby-2.3.0/gems/yarn-0.1.1/lib/yarn/server.rb:14:in <class:Server>': uninitialized constant Socket::SOL_TCP (NameError)
Error Stack:
$ yarn
.../.rvm/gems/ruby-2.3.0/gems/yarn-0.1.1/lib/yarn/server.rb:14:in <class:Server>': uninitialized constant Socket::SOL_TCP (NameError)
Did you mean? Socket::SO_TYPE
from .../.rvm/gems/ruby-2.3.0/gems/yarn-0.1.1/lib/yarn/server.rb:6:in <module:Yarn>'
from .../.rvm/gems/ruby-2.3.0/gems/yarn-0.1.1/lib/yarn/server.rb:4:in <top (required)>'
from .../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require'
from .../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require'
from .../.rvm/gems/ruby-2.3.0/gems/yarn-0.1.1/bin/yarn:26:in <top (required)>'
from .../.rvm/gems/ruby-2.3.0/bin/yarn:23:in load'
from .../.rvm/gems/ruby-2.3.0/bin/yarn:23:in <main>'
from .../.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in eval'
from .../.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Any ideas on the cause of this?

You may have the yarn gem installed (a web-server) and its associated executable at the same time that you are running the yarn command for the package manager. If so, and you intend to use the package manager, then simply gem uninstall yarn and y to remove the executable when prompted. All that you should need to run the package manager is to brew install yarn.

You should delete yarn gem:
gem uninstall yarn
and install yarn again:
yarn
yarn install v1.9.2.
success Already up-to-date.
✨ Done in 0.77s.
And after that, last step
yarn build
248 hidden modules ✨ Done in 4.95s.

I was getting the same error in ruby-2.2.4. I was able to overcome the problem by updating ruby to the latest version.
It looks like the Socket Server is crashing, so older ruby version may have an updated socket class?

Related

Ruby on Windows: `ansi.rb` get_screen_size error: in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)

I'm trying to use fastlane on Windows, which is installed from Bundler -- which is installed by Ruby Gem. But while running, some internal error of Ruby seems blocked the execution.
First, I went to Ruby Installer and installed Ruby+Devkit 3.0.2-1 (x64); then, I installed the Bundler and Fastlane using gem command. Error below happened when I was trying to execute them -- which I believed was not related to Bundler nor Fastlane:
C:/Ruby30-x64/lib/ruby/3.0.0/reline/ansi.rb:157:in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)
from C:/Ruby30-x64/lib/ruby/3.0.0/reline/ansi.rb:157:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:168:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/3.0.0/forwardable.rb:238:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:236:in `size_from_readline'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:66:in `size'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:76:in `width'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane_core/lib/fastlane_core/print_table.rb:95:in `transform_output'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/plugins/plugin_manager.rb:335:in `print_plugin_information'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/plugins/plugin_manager.rb:316:in `load_plugins'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/commands_generator.rb:39:in `start'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/cli_tools_distributor.rb:122:in `take_off'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/bin/fastlane:23:in `<top (required)>'
from C:/Ruby30-x64/bin/fastlane:23:in `load'
from C:/Ruby30-x64/bin/fastlane:23:in `<main>'
I'm using Windows 10 home version 20H2.
Rebooting the computer doesn't solve the problem.
I tried googling the question, but it seems that problem hasn't be reported (or be answered). I don't know where I can report the bug either.
What can I do? Any help would be appreciated!
I had this same error when I tried running bundle exec fastlane in git bash.
I got it working by running it in powershell instead.

Gitlab dpl issue with ruby version

I have a node app that I am deploying through Gitlab. I am using docker image node:12.8.0.
Recently it has been failing deployment with the following error
$ dpl --provider=heroku --app=$HEROKU_DEVELOPMENT_APP --api-key=$HEROKU_API_KEY --skip-cleanup
Installing deploy dependencies
ERROR: Error installing dpl-heroku:
    faraday requires Ruby version >= 2.4.
Successfully installed multipart-post-2.1.1
Successfully installed ruby2_keywords-0.0.2
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- dpl/provider/heroku (LoadError)
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/provider.rb:93:in `rescue in block in new'
    from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/provider.rb:68:in `block in new'
    from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/cli.rb:41:in `fold'
    from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/provider.rb:67:in `new'
    from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/cli.rb:31:in `run'
    from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/cli.rb:7:in `run'
    from /var/lib/gems/2.3.0/gems/dpl-1.10.15/bin/dpl:5:in `'
    from /usr/local/bin/dpl:22:in `load'
    from /usr/local/bin/dpl:22:in `'
Running after_script
00:01
Running after script...
$ echo "Job - $CI_JOB_NAME ended."
Job - deploy_development ended.
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
I am unable to install Ruby2.4 through apt-get install ruby2.4.
Any advice would be appreciated.
Thanks
I had the same problem today in Gitlab CI.
The problem is that Node uses debian stretch (version 9) by default as the base for docker images, at least in the 12.x LTS versions. This version of debian has Ruby 2.3.3 by default in the repositories, which is not supported by Faraday, which requires a version equal to or greater than 2.4.
What I did was use the 12.x-buster tag (notice the -buster at the end of the version tag) and in these images of docker Node uses debian buster (version 10) as a base. This version of debian has Ruby 2.5.5 repositories by default, which allows Faraday to be installed and therefore dpl for heroku works normally.
Those running into this issue on travis-ci, I was able to do it by adding a before_deploy command to specify the version of faraday to use.
...
before_deploy:
- rvm $(travis_internal_ruby) --fuzzy do ruby -S gem install faraday -v 1.8.0
deploy:
provider: heroku
api_key: $HEROKU_API_KEY
...
More details: https://travis-ci.community/t/heroku-deploy-fails-installing-dpl-heroku-encounters-faraday-error/12563/6?u=hallmanitor

Invalid spec cache file

I have ruby 2.0.0p247 [x64-mingw32] with Gem 2.2.2 installed on Windows 8. I have a persistent problem gem that is making it virtually unusable. Whenever I try to install a new gem, I invariably get:
ERROR: While executing gem ... Invalid spec cache file in C:/Users/...
In the past, I've been able to run gem update or gem update --system and that would clear up the problem for one, single gem install. Subsequent install would fail with the same error. Now even gem update fails with that error message.
I've tried deleting the users/.../.gem directory. When I do that, gem update recreates that directory and promptly fails with the same error message.
I re-installed ruby 1.9.8 with gems several times to try to cure the problem, then upgraded to ruby 2.0.0. Throughout all re-installs and upgrades, the problem persisted.
I'm at my wits end here. Can anyone help me resolve this issue?
Here's the backtrace on the edit"
L:\xampp\htdocs\frameworks\yii2\framework>gem update --backtrace
Updating installed gems
ERROR: While executing gem ... (Gem::Exception)
Invalid spec cache file in C:/Users/Larry/.gem/specs/rubygems.org%443/specs.4.8
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source.rb:187:in `rescue in load_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source.rb:179:in `load_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:266:in `tuples_for'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:228:in `block in available_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source_list.rb:97:in `each'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source_list.rb:97:in `each_source'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:222:in `available_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:102:in `search_for_dependency'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:113:in `fetch_remote_gems'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:135:in `highest_remote_version'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:264:in `block in which_to_update'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:260:in `each'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:260:in `which_to_update'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:96:in `execute'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command.rb:305:in `invoke_with_build_args'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command_manager.rb:167:in `process_args'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command_manager.rb:137:in `run'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:54:in `run'
C:/Ruby200-x64/bin/gem:21:in `<main>'
I had the same problem, but was able to fix it this way:
Delete the folder in users/%user%/.gem/ and rerun the command gem sources --update
Hope this helps.

undefined method get_uptime for Facter::Util::Uptime:Module (NoMethodError)

I'm trying to setup a puppet node, but rubygems doesn't seem to behave.
If I run facter on the cli via it's own binary (/usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter), it works fine, but if I run it through the binary installed by rubygems (/usr/bin/facter), it throws:
/usr/lib/ruby/1.8/facter/uptime.rb:11: undefined method `get_uptime' for Facter::Util::Uptime:Module (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:73:in `load'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:73:in `load_file'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:38:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:33:in `each'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:33:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:30:in `each'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:30:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/collection.rb:90:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter.rb:95:in `to_hash'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter:137
from /usr/bin/facter:19:in `load'
from /usr/bin/facter:19
I've tried removing rubygems and reinstalling as well as reinstalling the gem, but nothing seems to work.
I'm assuming something is cached somewhere, because it throws the same error when I'm trying to run puppet.
Any ideas?
It looks like you may have installed facter outside of rubygems before installing it with rubygems.
You'll notice the final file in the stacktrace is /usr/lib/ruby/1.8/facter/uptime.rb instead of being a file in /usr/lib/ruby/gems/1.8/gems/facter-1.5.8.
You should check if the files in /usr/lib/ruby/1.8/facter are indeed just an older version of factor and if so, you should be able to delete them or move them to a differently named directory and it will fix your problems.

Merb, Bundler, RVM and 1.9.1 = Could not locate Gemfile (Bundler::GemfileNotFound)

Can anyone suggest how to fix this (Ubuntu 9.10):
/home/chris/.rvm/gems/ruby-1.9.1-p378/gems/bundler-0.9.26/lib/bundler/shared_helpers.rb:42:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
from /home/chris/.rvm/gems/ruby-1.9.1-p378/gems/bundler-0.9.26/lib/bundler/shared_helpers.rb:51:in `env_file'
from /home/chris/.rvm/gems/ruby-1.9.1-p378/gems/bundler-0.9.26/lib/bundler.rb:143:in `env_file'
from /home/chris/.rvm/gems/ruby-1.9.1-p378/gems/bundler-0.9.26/lib/bundler.rb:174:in `update_env_file?'
from /home/chris/.rvm/gems/ruby-1.9.1-p378/gems/bundler-0.9.26/lib/bundler.rb:95:in `load'
from /home/chris/.rvm/gems/ruby-1.9.1-p378/gems/bundler-0.9.26/lib/bundler.rb:76:in `gem_setup'
from /home/chris/.rvm/gems/ruby-1.9.1-p378/gems/merb-core-1.1.2/bin/merb:10:in `rescue in <top (required)>'
from /home/chris/.rvm/gems/ruby-1.9.1-p378/gems/merb-core-1.1.2/bin/merb:3:in `<top (required)>'
from /home/chris/.rvm/gems/ruby-1.9.1-p378/bin/merb:19:in `load'
from /home/chris/.rvm/gems/ruby-1.9.1-p378/bin/merb:19:in `<main>'
Thank
Chris
Update
I tried really hard to get this to work. Eventually I fell back to merb-core 1.0.12 and that worked fine.
Solution
I needed to write a Gemfile for my application and drop it into the root directory for the app.
I was upgrading across too many versions of Merb! My application was a flat, Rack application originally developed with a much older version of Merb. It didn't have (or need) a Gemfile. When I ran it against the latest Merb, the error was thrown. It would have been better if it said 'I can't find the Gemfile for your application'
I ran merb-gen to get a basic Gemfile and updated it with my own requirements.
Hope that helps someone!
Looks like you need a gem, and a dependency to build that gem.
This might help, it helped me: postgres
(on ubuntu)
sudo apt-get install ruby-full build-essential postgresql-server-dev-8.3 (or 8.4)
sudo gem install postgres
heroku uses postgresql-server-dev-8.3 if you're deploying there.

Resources