NameError when trying to run simple ruby commands from irb - ruby

Anyone know why I would get this error: " NameError: undefined local variable or method `list' for main:Object
from (irb):1"
anytime i try to run a ruby command such as "gem list" from irb?
excuse my ignorance , ik nothing about Ruby and all im trying to do is install cocoapods to use with my ios projects.

It's because gem list is not "ruby command". It's shell command to list all ruby gems installed on your machine. You should use this outside ruby's irb console.

Related

Ruby gem tensorflow.rb example not working

I am trying to run the ruby tensorflow example.rb file, as described here. I have installed tensorflow.rb using docker, as described here. When I run bundle exec rspec spec, all examples pass.
I have created a file example.rb as instructed. When I run the file using ruby example.rb, I get the following error
/usr/local/rvm/gems/ruby-2.2.4#ruby-tensorflow/gems/tensorflow-0.0.1/lib/tensorflow/session.rb:168:in `graph_def_to_c_array': undefined method `length' for nil:NilClass (NoMethodError)
from /usr/local/rvm/gems/ruby-2.2.4#ruby-tensorflow/gems/tensorflow-0.0.1/lib/tensorflow/session.rb:51:in `extend_graph'
from example.rb:9:in `<main>'
When I run each line of example.rb in an irb session, the error occurs at the command:
session.extend_graph(graph)
How do I fix this?
This was raised as an issue. It turned out that the docker image was out of date. It has been fixed, so if you follow the new Readme instructions, then it now all works.

Trying to use line comand in gem: gem install shopify_theme

I am new to ruby and am trying to use the line command:
gem install shopify_theme
However, I get an error
NameError: undefined local variable or method 'shopify_theme' for main:Object
from <rb>:2
from C:/Ruby21/bin/irb:11:in '<main>'
I assume this has something to do with my local files? I've used Dir.chdir to target my folder. Also, I have the gem file here as well.
ref: https://github.com/Shopify/shopify_theme
Thank you and any help is greatly appreciated!
You may be in the ruby console. Exit the ruby console and use cmd.exe!

Ruby Gems "NameError: undefined local variable or method 'update' for main:Object" on every command

I'm attempting to set up a Watir environment. I had several issues actually installing the gems necessary, so I uninstalled and reinstalled Ruby 1.9.3 (I'm running Windows 7.) Now, I can't do any installs, updates, etc. from the ruby command line. Here is an example of some simple commands that should work but are not:
C:\Users\Matt Adams>irb
irb(main):001:0> gem -v
NameError: undefined local variable or method `v' for main:Object
from (irb):1
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):002:0> gem update
NameError: undefined local variable or method `update' for main:Object
from (irb):2
from C:/Ruby193/bin/irb:12:in `<main>'
I can start ruby irb, but that's it. Its almost as if none of the ruby commands were installed. Anyone have any suggestions? Note that I've already done a re-install.
IRB is there for you to try out Ruby commands or snippets and see immediate responses. If you want to install or update gems, I suggest you get off IRB first by running "quit" and follow whatever instructions you have on your hand.

Ruby Net::SSH undefined method 'shell'

I'm trying to log into a remote machine using SSH in my Ruby code and then trying to cd into another directory once I SSHed in. Here is my Ruby code to do it
require 'net/ssh'
require 'rubygems'
require 'needle'
Net::SSH.start('host', 'shui', :password => "password") do |ssh|
output = ssh.exec!("hostname")
shell = ssh.shell.open
shell.pwd
shell.cd "/svn"
puts shell.pwd
end
when I run my script, it gives me this error:
testssh.rb:8:in `block in <main>': undefined method `shell' ... (NoMethodError)
I'm pretty sure I've installed the gems that are needed to do this. Any suggestions on how to fix this? Thanks!
There is no shell method in Net:SSH v2, the yielded object is a Net::SSH::Connection::Session.
This net-ssh extension gives you the feature you are looking for: https://github.com/mitchellh/net-ssh-shell
Can you check your version?
gem list --local | grep ssh
i have 2.5.2
I found multiple references online, but you should use:
http://net-ssh.rubyforge.org/ssh/v2/api/classes/Net/SSH.html
here is the reference to v1
http://net-ssh.github.com/ssh/v1/chapter-5.html
the later, uses the shell method. But i don't think you have that gem installed.
So have a look at the 1st one (v2). Thats working fine for me.

IronRuby doesn't recognize 'rake' - I'm getting undefined method `rake' for main:Object, how to fix?

Just installed IronRuby 1.1. I'm trying to take a look at rake and albacore. After installing ironruby, I am able to hit a command prompt by typing ir, and I am able to do simple puts, but when I try to run rake, I get the error
undefined method `rake' for main:Object
How do I resolve this? Any ideas?
Thanks,
~ck in San Diego
rake is an executable Ruby script that you call from the Windows command line, not a Ruby method that you call from IRb.

Resources