I'm getting a lot of syntax errors:
SyntaxError: /Users/davidtuite/dev/ruby/seenbefore_client/spec/lib/url_group_spec.rb:40: syntax error, unexpected ':'
records = stub(length: length)
yet the JRuby Blog says that "Compiler handles all 1.9 syntax now" since JRuby 1.6.0.rc2.
I'm using JRuby 1.6.5
rvm info
ruby:
interpreter: "jruby"
version: "1.6.5"
date: "2011-10-25"
platform: "darwin-x86_64-java"
patchlevel: "TM"
full_version: "jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]"
JRuby can be made 1.9.2-compatible by adding the --1.9 command line switch or by adding that switch to the JRUBY_OPTS environment variable:
$ export JRUBY_OPTS='--1.9'
$ bin/irb
irb(main):001:0> RUBY_VERSION
=> "1.9.2"
irb(main):002:0> {asd:3}
=> {:asd=>3}
Don't know how you can tell your RVM that, though. By the way, on Windows the batch syntax is set JRUBY_OPTS=--1.9.
Related
Installed ruby 2.4.0 using RVM, but after typing ruby, the command just freezes indefinitely. Can be ctrl-C'ed out, but ruby never loads.
Ruby info:
ruby-2.4.0:
system:
uname: "Linux waffleboy 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux"
name: "Ubuntu"
version: "16.04"
architecture: "x86_64"
bash: "/bin/bash => GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)"
zsh: "/usr/bin/zsh => zsh 5.1.1 (x86_64-ubuntu-linux-gnu)"
remote path: "ubuntu/16.04/x86_64"
rvm:
version: "rvm 1.29.2 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]"
updated: "23 minutes 20 seconds ago"
path: "/home/waffleboy/.rvm"
autolibs: "[4] Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X)."
ruby:
interpreter: "ruby"
version: "2.4.0p0"
date: "2016-12-24"
platform: "x86_64-linux"
patchlevel: "2016-12-24 revision 57164"
full_version: "ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]"
homes:
gem: "/home/waffleboy/.rvm/gems/ruby-2.4.0"
ruby: "/home/waffleboy/.rvm/rubies/ruby-2.4.0"
binaries:
ruby: "/home/waffleboy/.rvm/rubies/ruby-2.4.0/bin/ruby"
irb: "/home/waffleboy/.rvm/rubies/ruby-2.4.0/bin/irb"
gem: "/home/waffleboy/.rvm/rubies/ruby-2.4.0/bin/gem"
rake: "/home/waffleboy/.rvm/rubies/ruby-2.4.0/bin/rake"
environment:
PATH: "/home/waffleboy/.rvm/gems/ruby-2.4.0/bin:/home/waffleboy/.rvm/gems/ruby-2.4.0#global/bin:/home/waffleboy/.rvm/rubies/ruby-2.4.0/bin:/storage/anaconda3/bin:/home/waffleboy/bin:/home/waffleboy/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/bin:/storage/programfiles/:/home/waffleboy/bin:/storage/programfiles/spark-1.6.2/bin:/home/waffleboy/.rvm/bin"
GEM_HOME: "/home/waffleboy/.rvm/gems/ruby-2.4.0"
GEM_PATH: "/home/waffleboy/.rvm/gems/ruby-2.4.0:/home/waffleboy/.rvm/gems/ruby-2.4.0#global"
MY_RUBY_HOME: "/home/waffleboy/.rvm/rubies/ruby-2.4.0"
IRBRC: "/home/waffleboy/.rvm/rubies/ruby-2.4.0/.irbrc"
RUBYOPT: ""
gemset: ""
Rvm list:
rvm rubies
=* ruby-2.4.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
I've tried reinstalling and installing ruby multiple times but it just doesn't seem to work.
Can anyone point me in the right direction? :) Thank you!
This is normal; it is a feature, not a bug.
Running ruby, without any parameters, causes the program to run and wait to receive input from STDIN (ending with an EOF character). It will not execute anything until it receives this information.
If you want to run ruby in interactive mode, (like when you run python), then use ruby's built-in irb ("interactive ruby") command.
Alternatively, if you just want to display some basic information about the ruby version installed then you can try commands like:
ruby -v # Display version information
ruby -h # Display help about usage, switches and features
If you're looking for a REPL to type Ruby code into, have it executed, and see the results, then you're looking for the irb command, not ruby.
ruby is for running files (eg. ruby my_file.rb), or without arguments will read a script typed into standard input, which will get executed when you quit ruby with cmd+D.
I am getting syntax error, unexpected tLABEL in below Ruby code. The error description is pointing to ':' after 'timeout'.
def self.run(*args, timeout: nil, environment: {})
# ...
end
I have no knowledge of Ruby. I have tried few things like replacing ':' with '=' or putting nil in {} but nothing seems to work.
My ruby version is 2.1.5.
IUQ-mini:~ IUQ$ rbenv versions
system
* 2.1.5 (set by /Users/IUQ/.ruby-version)
2.1.7
2.2.3
The particular code can be found here at line #38.
Few questions over SO points that this could happen due to misplaced braces but I did not see error - again my lack of Ruby knowledge!
Please help me to understand cause of this error and How can I resolve this?
Thanks
That won't work in ruby 1.9 (if in fact JRuby is limiting you to 1.9) as-is since the splat is expected to have a hash immediately following it if it's the first argument.
You can do something like this:
def self.run (environment = {}, timeout = nil, *args)
end
The only rub is you'll have to explicitly pass something (even nil) for timeout if you want to pass stuff in to be args[].
Calabash iOS and Android require ruby >= 2.0.
The latest released version of ruby is recommended.
JRuby of any version is not supported at this time.
Travis build
If you look at the info for that build, you'll see it failed because it was running on ruby 1.9.3.
I believe that you have ruby 2.0 installed. I don't think you are using it.
$ rbenv versions
system
1.8.7-p375
1.9.3-p484
2.0.0-p481
2.1.5
2.2.2
2.2.3
* 2.3.0 (set by /Users/moody/.rbenv/version) <== Active ruby in this dir
jruby-1.7.18
$ rbenv version # Active ruby in this directory
2.3.0
You never mentioned what version of run_loop you are using. You should update to the most recent stable release.
https://github.com/calabash/calabash-ios/wiki/Updating-your-run-loop-version
I'm trying to set the language mode in Rubinius, and it doesn't seem to work. I tried using the switch suggested by the Rubinius team in April 2012 in https://stackoverflow.com/a/10165964/38765
$ ruby --version
rubinius 2.0.0.n203 (1.9.3 4d75a146 2013-07-22 JI) [x86_64-apple-darwin11.4.2]
$ ruby -X18
irb(main):001:0> RUBY_VERSION
=> "1.9.3"
irb(main):002:0> exit
$ ruby -X20
irb(main):001:0> RUBY_VERSION
=> "1.9.3"
Is it possible to set language mode any more for Rubinius?
You have to enable the language modes when compiling rubinius. From the docs:
For example, to enable both 1.9 and 2.0 modes, with 1.9 the default,
use the follwing configure options:
./configure --enable-version=1.9,2.0 --default-version=1.9
1.9.3-p194 :059 > arabic
=> "أَبْجَدِيَّة عَ"
1.9.3-p194 :065 > arabic.encoding
=> #<Encoding:UTF-8>
1.9.3-p194 :068 > "begin #{arabic} end " + " Goodbye "
=> "begin أَبْجَدِيَّة عَ end Goodbye "
1.9.3-p194 :067 > "#{arabic} end " + " Goodbye "
=> "end Goodbye أَبْجَدِيَّة عَ"
I want the last output to read " أَبْجَدِيَّة عَ end Goodbye ".
What character encoding hoops do I have to go through to get ruby to ignore that the arabic is a RTL language?
UPDATE:
I was able to reproduce this in the following rubies:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_15-b03 [linux-amd64]
jruby 1.7.4 (1.9.3p392) 2013-06-07 fffffff on Java HotSpot(TM) 64-Bit Server VM 1.7.0_15-b03 [linux-amd64]
Here is a gist with the code from above
This is a bug that has been fixed. Ruby has no idea that Arabic is a RTL language. Can't replicate it on either 2.0.0-p0, 1.9.3-p392, or any other Ruby I have installed. Try upgrading to a recent version of 1.9.
Simple solution could be to use Left-to-right mark, here is html example:
"#{arabic_str1}"+" "+"#{arabic_str2}"
Works well for me (1.9.3p392 ruby version).
I am reading a book "Working with Unix Processes" which uses ruby to explain about unix/linux processes. This is my first time working with ruby. I tried an example to get resource limits on processes.
irb(main):001:0> Process.getrlimit(:CORE)
Errno::EINVAL: Invalid argument - getrlimit
from (irb):1:in `getrlimit'
from (irb):1
from :0
irb(main):004:0> Process.getrlimit()
ArgumentError: wrong number of arguments (0 for 1)
from (irb):4:in `getrlimit'
from (irb):4
from :0
But I can't seem to get "getrlimit" recognized (though it says I have wrong number of arguments if I don't supply any args). Haven't found anything on this on google or SO. Tried with :NOFILE, :CORE and others. Is there something I need to include/require to make getrlimit work. Environment:
Ubuntu 11.04 32 bit. Kernel 3.0.0-14
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
irb 0.9.5(05/04/13)
regards
Sorry .. never mind. It seems that IRB was running a previous version of ruby (1.8.7) which somehow didn't support the getrlimit (though according to all accounts on google, it should have worked). I had upgraded ruby to 1.9.1 but did not update the link from /usr/bin/irb to /usr/bin/irb1.9.1. So IRB was still running ruby 1.8.7. After updating the softlink of irb to v1.9.1, getrlimit is now working.