Updating Ruby Version in Visual Studio Code - ruby

I am using Visual Studio Code on my macOS where I am trying to update the version of Ruby I am using within a project from ruby 2.0.0p648 to a newer version of Ruby (I have tried a number of different versions). I have tried much of the information on this site to make the updates from this site and others, but no luck.
I have tried:
curl -L https://get.rvm.io | bash -s stable –ruby
rvm install ruby-2.4.0
rvm use ruby-2.4.0 --default
But when checking that I am using / installed 2.4.0 by using ruby -v, it still comes back with 2.0.0p648.
When I run those commands via the Apple Terminal the response I receive from asking for the version comes back with 2.4.0.
How can I fix this issue?
Thanks.

If your project has a gemfile with the ruby version specified, then RVM will pick it up when you CD to the project folder from command line. VS code doesn't seem to do this till I added "cwd" to the launch config and then it works as expected. Here is my launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"program": "${workspaceRoot}/bin/rails",
"args": [
"server"
],
"useBundler": true,
"showDebuggerOutput": true,
"cwd": "${workspaceRoot}"
}
]
}

I don't have a Mac, but since RVM is available on Linux, I've tried working with it in WSL, as well as Windows with Railsinstaller, so I have some experience.
Actually, this isn't even about VS Code, but MAYBE, since Mac has an old Ruby version available not contained within the version manager, this happens.
First of all, note all the available versions (inside RVM, well as the one which is shown by the terminal), and uninstall all versions outside of RVM.
Keep this with you just for backup, if incase, anything goes wrong, you can reinstall them.
Next try setting the preferred Ruby version using RVM.
Try finding out the Ruby version
ruby -v
If that matches your description, you're good to go.

Definitely, it about your IDE's config about ruby-path, find where can set ruby-path and set the correct rvm-ruby-path.

Related

Debugging (Old) Ruby Rack via VsCode

I been task to update an old ruby (2.4.10) project.
The project is a simple API server written using Cuba and Rack.
(Note that the project uses dep).
I'm trying to setup a working environment on my mac (using rbenv) and would like to debug the API server via VsCode. After hours of searching and testing all sort of launch.json configuration I came up empty.
I have created the most minimal representation of the project in at the following repo https://github.com/dannyhuly/ruby-rack.
Any help would be greatly appreciated.
FYI
I'm a ruby newbie and would like to learn as mach as I can. So any additional information and suggestions would be greatly appreciated as well.
I ran a debug session with your project using the Ruby extension.
As explained in the vscode-ruby debugger docs, first I had to install the ruby-debug-ide and the debase gems.
Then I used the following launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Rack",
"type": "Ruby",
"request": "launch",
"program": "~/.rbenv/versions/2.4.10/bin/rackup",
"args": []
}
]
}
If there's any issue starting the session, you should be able to see error logs in the debug console panel in VSCode.

Travis CI : Nightwatch js: Error while trying to create ChromeDriver process: spawn EACCES. Running perfectly locally

Error: enter image description here
Code:
"webdriver" : {
"start_process": true,
"server_path": "./drivers/chromedriver.exe",
"port": 9515,
},
For starters, it looks like you're trying to run the Windows chromedriver on a Linux Travis CI instance.
You probably want to have two different sets of test settings, one for Windows and one for Linux. Or else configure Travis CI to use Windows.
I'm not sure what version of Chrome (or Chromium?) is installed by default in Travis CI instances; to get the latest stable version, add this to your .travis.yml:
addons:
chrome: stable
See https://docs.travis-ci.com/user/chrome
Then, for the nightwatch config, it should be
"server_path": "node_modules/.bin/chromedriver",
That was enough to get me working today but I'm afraid that there might be one more issue that I haven't figured out yet: travis CI doesn't let you specify a specific version of Chrome to install, but chromedriver versions are matched to Chrome versions. I put my chromedriver version as * to always install the latest, but I have a feeling that my current config is going to fail eventually, so if anyone else figures that out, please leave a comment here.

version of Ruby for cucumber

I have no knowledge in Ruby, but I need to run some tests in it. The code is in Ruby and Cucumber. I use intellij on Mac. When I first open intellij cucumber step definition where not recognised from feature file. In terminal I got:
Required ruby-2.1.2 is not installed.
To install do: 'rvm install "ruby-2.1.2"'
but
$ which ruby
/Users/myuser/.rvm/rubies/ruby-2.4.1/bin/ruby
so I run the install command as suggested and now I get
$ which ruby
/Users/myuser/.rvm/rubies/ruby-2.1.2/bin/ruby
Now my feature files connected to step definition as well. I will appreciate if anyone could explain me what happened. What prompted me to downgrade the version of Ruby and how it fixed cucumber.
Make sure you have ruby 2.1.2 set in File -> Settings -> Languages & Frameworks -> Ruby SDK and Gems
What I suspect is happening is you have run rvm use 2.1.2 in the terminal but when your IDE runs something it is using the ruby version set in the settings.
You probably have a .ruby_version file in the project root directory. This will enforce a specific version of Ruby. So the person who put it there is who to ask why the version was restricted like that. There may have been a good reason, such as that's what is being used by all your users.
It has nothing to do with Cucumber. rvm has some kind of operating system hook, I think, that runs whenever you cd into a directory. It looks for its special control fiels such as .ruby_version and .rvmrc file. This page describes this in more detail: https://rvm.io/workflow/projects.

Installing casperJS 1.1.0 Dev on Windows 8

I am trying to install casperJS on Windows 8. First I install phantomjs 1.8.2
I go to http://casperjs.readthedocs.org/en/latest/installation.html
Download the zip under "Latest stable version". The site says its ver 1.0.3
I need 1.1.0 so I download the zip under "Latest development version (master branch):"
When I unzip it, add the path to PATH_VARIABLE and run it, I get error:
"CasperError: Can't find module cli"
Can someone plz tell from where can I get casperJS 1.1.0 for win8 ? I have spent entire day in this !
Are you using Visual Studio Node tools? (For some reason, with this package, attempting to install via the typical approach seemed to fail.) I was able to get installation to work by adding the casperjs line to my package.json file:
"dependencies": {
"cheerio": "^0.19.0",
"express": "^4.13.3",
"request": "^2.61.0",
"casperjs": "^1.1.0-beta3"
}
When I saved the file, Visual Studio ran npm install, which successfully installed the package. Running the command manually after updating the package.json and CD'ing into the appropriate directory should achieve the same results.

How to tell Terminal which version of Ruby to use?

I have two related questions that I was hoping someone could help out with.
I recently installed Ruby 1.9.2 on my Mac (running Snow Leopard 10.6.4) and I haven’t been able to figure out how to get Terminal to use the new Ruby as a default, rather than the factory-installed Ruby 1.8.7. The old Ruby 1.8.7 is located in my ~/usr/bin/ruby directory while the new Ruby 1.9.2 is in ~/usr/local/bin/ruby. Someone said that I need to put the new version of Ruby's directory in the PATH prior to the old version's directory so that the system looks there first - is this correct? If so, can anyone provide step by step instructions on how to do this?
I’ve created a new directory but can’t seem to figure out the correct way to add that directory to my PATH using the Terminal bash shell. I tried using the instructions that I found here (http://www.macgasm.net/2008/04/10/ad...thin-terminal/) twice but they didn't work for me. The directory containing my program ("Ruby_Programs") shows up in the PATH but when I try to run "ruby newprogram.rb" from the command line it results in ":ruby: No such file or directory -- newprogram.rb (LoadError)". The file definitely exists and is a functional Ruby program. I did change the name of the directory to "Ruby Programs" and then back to "Ruby_Programs" - could that have somehow caused this problem?
Any help would be greatly appreciated. Here is my current PATH:
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/sbrriffe/src:/usr/X11/bin:/Users/sbriffe/Ruby_Programs/:
You might want to check out rvm. You can install multiple versions of ruby side by side and easily switch between them. If you follow the rvm installation notes you won't have any more path problems.
Your Ruby Programs directory shouldn't be in your path: the location of your ruby interpreter should be. Then, you cd to the location of your ruby program, and run it from there: ruby program.rb.
Since you are on a Mac, check out homebrew for something that will make installing software easier. I have my homebrew set up in /usr/local, and it works great.
Once you have installed stuff where you need it, then you'll want to adjust your $PATH. The items in $PATH are searched in the order they appear, so in your ~/.bashrc, you'll want to add:
export PATH=/usr/local/bin:$PATH
To make sure /usr/local/bin gets searched before /usr/bin.
I would use RVM to get everything installed, and then once you have RVM installed it is easy to set your default Ruby version.
Check out https://rvm.io/ -- once you have that installed you can change your default by using : $ rvm use 1.9.2 --default
hope that helps- you can do this with any version, not only 1.9.2

Resources