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.
Related
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.
This issues comes a goes depending on the Ruby project I'm working on. VSCode Tasks often do not run from the proper rbenv shimmed Ruby version. Sometimes, if I manually run a command from the integrated terminal first, then run the Code task it picks up the correct Ruby.
Example VSCode Task,
{
"version": "2.0.0",
"tasks": [
{
"label": "Run All Tests",
"type": "shell",
"command": "bin/rails test",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "shared"
}
}
]
}
When launching Code from the project directory (or any other way for that matter) if I run this task it runs from the context of the System ruby. However, if I open the integrated terminal and type bin/rails test (which works) then run the task again it will run in the proper rbenv shimmed ruby context.
Launching a debugger session however does work in the proper Ruby context, so I really don't understand what's being missed.
This answer will get tasks working, however it doesn't fix the underlying problem with VS Code. This probably needs to be an issue posted on their GitHub repo.
If you're on a Mac, this command will put a ruby symlink in your path that links to the rbenv version. Rbenv (and most applications) only change the path inside a shell environment (the .bash_profile only changes it for bash). This command will add it to the path regardless of what shell you run.
ln -s "/Users/$(whoami)/.rbenv/shims/ruby" /usr/local/bin/ruby
My guess is that VS Code is not actually using a shell environment and is instead calling the executable directly.
Until Visual Studio Code solves what seems to be a bug or missing configuration setting or, at least, missing documentation, I have resorted to setting the PATH variable on the task's command attribute.
For example, if the ruby I'm interested in using is at /full/path/to/bin/ruby, I prepend /full/path/to/bin to the PATH environment variable.
For example:
.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "sidekiq",
"type": "shell",
"command": "export PATH=/full/path/to/bin:$PATH && bundle exec sidekiq -C config/sidekiq.yml",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"runOptions": {
"runOn": "folderOpen"
}
}]
}
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.
Is it possible to use Bourbon and it's additional components without needing to have Ruby installed? We'd like to experiment on a small project, but it's a pain to get dependencies approved by the desktop engineering folks.
I've noticed that there are Bower packages for all but Bitters. Can I just grab the scss files from GitHub and wire things up manually?
Seems the devs don't want to have bitters on bower: https://github.com/thoughtbot/bitters/issues/22.
That said, you can get bitters with bower if you use a zipball from git as a version (e.g. https://github.com/thoughtbot/bitters/archive/master.zip).
If you want more control on how to bring those files in your project, gulp-bower-normalize can help — an example bower.json file:
{
"name": "project-x",
"dependencies": {
"bitters": "https://github.com/thoughtbot/bitters/archive/master.zip",
},
"overrides": {
"bitters": {
"main": [
"app/assets/stylesheets/*.scss"
],
"normalize": {
"css/base": "**/*.scss"
}
}
}
}
Had this same question recently as I'm using Bourbon/Neat in a static site project. I've found that the 'bourbon' and 'neat' commands do nothing more that replicate the hierarchy of library files into your project directory. At that point you can use the libraries with any workflow which is able to preprocess sass/scss files.
In my case I'm using them successfully with the Python WebAssets library from within Pelican, you might be able to find another sass preprocessor that fits into your setup.
If you can get node installed on your dev machine check out Yeoman. It uses Grunt and Bower to generate a web app that uses Sass. Then you can install Bourbon and Neat using Bower. It does a lot of the heavy lifting for you.
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.