gets function is causing an Invalid argument error - ruby

I'm having to learn ruby (not rails) due to a device that only runs ruby installed code.
I'm currently using v 1.9.3 on my Windows 10 desktop to study the syntax and I can't run any examples with the gets() function.
example:
name = gets()
without getting the error
test.rb:1:in `gets': Invalid argument - (Errno::EINVAL)
I haven't tried updating the version (Manufacturer's guide, though possible just out of date, listed installing 1.9) but I wouldn't think such a core function would be missing from this version.
puts() works just fine.
Thanks in advance for any direction...

Related

possible to use rbenv with ruby2 to install ruby3?

I'm trying to get ruby3 on ubuntu20.04 (which I must use for policy compliance reasons) and only includes ruby up to 2.7
this version of ubuntu provides rbenv, and the list of available interpreters have rbx-3.0. When i try to install it i get
bundler-1.3.6/lib/bundler/fetcher.rb:240:in dependency_api_uri': undefined method encode' for URI:Module (NoMethodError)
not sure if the versions are related, but since the error i am getting (undefined method encode' for URI:Module`) is often caused by ruby 2 code running ruby 3, i'm guessing this is the source of my predicament.
Is there a work around for this? or a smarter way to go about getting ruby3 on this OS?

Warning parser/current is loading parser/ruby22

I'm newbie in Ruby, while excecuting a command I got this error.
warning: parser/current is loading parser/ruby22, which recognizes
warning: 2.2-compliant syntax, but you are running 2.3.1.
My Ruby version is 2.3.1
My parser version is 2.4.0.0.
I don't know why parser is loading from ruby22 which is not even installed in my computer.
Any help would be appreciated.
In my case, I was running an old version of Rubocop (which relies on the parser gem). Removing/updating rubocop or whatever gem is using parser may fix your issue.

Problems with new command on Rails.vim

I've installed a plain instalation of Ruby on Windows (using Ruby Installer, so Ruby 2.0) and Rails. Also, I've installed GVim, and, using Pathogen, the plugin Rails.vim.
But, when I try to create a new application, using Vim, the following error occurs:
:Rails new MyApp
Error detected while processing Function rails#new_app_command
E118:Too many arguments for function: s:sub
E15: Invalid expression s:sub(&shellpipe, '%s', temp, 'g')
In command prompt the application is created without problems.
I already tried to create an empty .vimrc, with only pathogen command.
Also, I acess the plugin documentation throug gVim without problems.
What I'm doing wrong?
Thanks in advance!
As mentioned in comments (by romainl and Peter Rincker), it is a bug of the latest version of the plugin.
The Issue http://github.com/tpope/vim-rails/issues/344 was posted and solved. An update of my local version solved the problem. Now, everything works fine.

Error at the end of Installation of Ruby 2.0.0 on Mac Mountain Lion, also no mysql.sock file

I am a total noob to Ruby and Rails, so any help is appreciated about this.
I installed Ruby 2.0.0 using RVM. It got most of the way through, when I got this error message:
Error running 'env GEM_PATH=/Users/victoriamielke/.rvm/gems/ruby-2.0.0-p0:/Users/victoriamielke/.rvm/gems/ruby-2.0.0-p0#global:/Users/victoriamielke/.rvm/gems/ruby-2.0.0-p0:/Users/victoriamielke/.rvm/gems/ruby-2.0.0-p0#global GEM_HOME=/Users/victoriamielke/.rvm/gems/ruby-2.0.0-p0 /Users/victoriamielke/.rvm/rubies/ruby-2.0.0-p0/bin/ruby -d /Users/victoriamielke/.rvm/src/rubygems-2.0.3/setup.rb --verbose',
please read /Users/victoriamielke/.rvm/log/ruby-2.0.0-p0/rubygems.install.log
Installation of rubygems did not complete successfully.
I also opened up rubygems.install.log, and it said near the end:
ERROR: While executing gem ... (NoMethodError)
undefined method `fu_stream_blksize' for #<Gem::Commands::SetupCommand:0x007fcab29f5838>
What caused the failure of Rubygems to install?
Another problem am having is the error message ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2). I tried a Google search on this, which said I needed to find the mysql.sock file. Well, I have never found this file on my computer and could not find out in plain English how to add it or generate it.
Looks like the installation error is a recent known issue. If you're a beginner I recommend using Ruby 1.9.3, since 2.0.0 is brand new and you'll certainly find bugs in both the language implementation and libraries that haven't been tested on 2.0.0 yet.
The second issue is unrelated. It could be that you haven't started MySQL (did you run mysql.server start?), file permissions, MySQL configuration, or any number of other issues. You're not supposed to create /tmp/mysql.sock yourself, it's created automatically by MySQL. Please open a separate question about it.

Ruby 2.0.0p0 IRB warning: "DL is deprecated, please use Fiddle"

I just uninstalled my older versions of Ruby, removed all of my gems
(including Rails), and installed Ruby 2.0. In other words, a totally clean re-install. Upon starting IRB, I received this message:
DL is deprecated, please use Fiddle
Note: I'm on a Windows machine.
What does this message mean?
The message you received is common when you have ruby 2.0.0p0 (2013-02-24) on top of Windows.
The message "DL is deprecated, please use Fiddle" is not an error; it's only a warning.
The source is the Deprecation notice for DL introduced some time ago in dl.rb ( see revisions/37910 ).
On Windows the lib/ruby/site_ruby/2.0.0/readline.rb file still requires dl.rb so the warning message comes out when you require 'irb' ( because irb requires 'readline' ) or when anything else wants to require 'readline'.
You can open readline.rb with your favorite text editor and look up the code ( near line 4369 ):
if RUBY_VERSION < '1.9.1'
require 'Win32API'
else
require 'dl'
class Win32API
DLL = {}
We can always hope for an improvement to work out this deprecation in future releases of Ruby.
EDIT:
For those wanting to go deeper about Fiddle vs DL, let it be said that their purpose is to dynamically link external libraries with Ruby; you can read on the ruby-doc website about DL or Fiddle.
You may want to comment out the DL is deprecated, please use Fiddle warning at
C:\Ruby200\lib\ruby\2.0.0\dl.rb
since it’s annoying and you are not the irb/pry or some other gems code owner
I got this resolution at openshift.com.
Resolution:
This error occurs only on Windows machine with Ruby 2.0.0 version.
Until we officially support Ruby 2.0 please downgrade to Ruby 1.9.
On Windows, you can install Ruby 1.9.3 alongside 2.0. Change your
%PATH% to c:\ruby193\ or whatever directory you installed to prior
to installing the gem.
The message "DL is deprecated, please use Fiddle" is not an error; it's only a warning.
Solution:
You can ignore this in 3 simple steps.
Step 1. Goto C:\RailsInstaller\Ruby2.1.0\lib\ruby\2.1.0
Step 2. Then find dl.rb and open the file with any online editors like Aptana,sublime text etc
Step 3. Comment the line 8 with '#' ie # warn "DL is deprecated, please use Fiddle" .
That's it, Thank you.
I ran into this myself when I wanted to make a thor command under Windows.
To avoid having that message output everytime I ran my thor application I temporarily muted warnings while loading thor:
begin
original_verbose = $VERBOSE
$VERBOSE = nil
require "thor"
ensure
$VERBOSE = original_verbose
end
That saved me from having to edit third party source files.

Resources