I use RVM to change Ruby versions in my Mac-based development environment.
Inside Visual Studio Code, when I open a regular Terminal tab, I'm dropped into a bash login shell with the -l option, per the standard default configuration, and as documented here:
// VSCode default settings
{
"terminal.integrated.shell.osx": "/bin/bash",
"terminal.integrated.shellArgs.osx": [
"-l"
]
}
The RVM command executed manually from VSCode Terminal gives me the expected ruby version for this project by default.
$ rvm list
ruby-2.0.0-p648 [ x86_64 ]
ruby-2.1.10 [ x86_64 ]
ruby-2.1.5 [ x86_64 ]
ruby-2.2.10 [ x86_64 ]
ruby-2.2.5 [ x86_64 ]
ruby-2.3.0 [ x86_64 ]
* ruby-2.3.1 [ x86_64 ]
=> ruby-2.3.7 [ x86_64 ]
# => - current
# =* - current && default
# * - default
However, when I setup a .vscode/tasks.json file to execute that same command the Ruby version is NOT the correct version, but the default one on the system. Futhermore, I'm unable to actually use rvm use to switch versions (see error message below)
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Check for RVM",
"type": "shell",
"command": "rvm list && rvm use 2.3.7",
"group": {
"kind": "test",
"isDefault": true
}
}
}
}
Output of task execution, with error message about not having a correct login shell.
> Executing task: rvm list && rvm use 2.3.7 <
ruby-2.0.0-p648 [ x86_64 ]
ruby-2.1.10 [ x86_64 ]
ruby-2.1.5 [ x86_64 ]
ruby-2.2.10 [ x86_64 ]
ruby-2.2.5 [ x86_64 ]
ruby-2.3.0 [ x86_64 ]
=* ruby-2.3.1 [ x86_64 ]
ruby-2.3.7 [ x86_64 ]
# => - current
# =* - current && default
# * - default
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.
Terminal will be reused by tasks, press any key to close it.
I've even tried specifically adding the -l bash command option as an argument in the Task's configuration, but this does not work.
"options": {
"shell": {
"args": "-l"
}
}
My understanding, after reading through this issue is that the Terminal shell config and the Task shell config is one and the same, so is there some other underlying inconsistency between Terminal shell and Task shell that I'm missing? If not, then what is it about RVM that prevents it from working inside a Task shell?
RVM overrides the 'cd' command to detect the .ruby-version and .ruby-gemset files and automatically set up your environment. A newly initiated vscode terminal doesn't trigger that. It only uses the default or current settings from when vscode was started, NOT what you have defined in your .ruby* files.
So I usually run cd $PWD when starting a new terminal in vscode.
When defining a rake task in tasks.json, my command line is like so:
{
"label": "rake db:migrate",
"type": "shell",
"command": "cd $PWD; rake db:migrate",
"problemMatcher": []
},
Note the cd $PWD prepended to the command line, to hook into rvm.
It's kludgy. But it's working for me so far.
I suspect this non-awareness of rvm/.ruby-gemset/.ruby-version is also preventing vscode's automatic detection of rake tasks that the Ruby plugin is supposed to do, as mentioned here https://medium.com/hack-visual-studio-code/rake-task-auto-detection-in-vscode-ce548488755e. So any rake tasks I want to run via vscode tasks have to be defined manually by me this way.
Hope this helps.
I had similar issue with starting up Rails inside VS Code tasks on MacOS, with zsh as default shell.
Fix was to use --login vs -l. For example:
{
"label": "Rails Sample",
"type": "shell",
"command": "cd rails-sample && bin/rails server",
"options": {
"shell": {
"args": ["--login"]
}
},
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "rails-sample"
}
}
When I was using -l it would show me error like:
Your Ruby version is 2.6.3, but your Gemfile specified 3.0.2
The terminal process "/bin/zsh '-c', 'cd rails-sample && bin/rails server'" terminated with exit code: 18.
The reason I tried --login was because I came across this issue, even though I have the latest version of VS Code. It could be due to setup on my machine.
Related
I'd like to run the command reload -b whenever a terminal opens in Visual Studio Code on a Mac. The accepted answer to a similar question gives a deprecated warning.
I've set my default profile (ZSH) and configured it as suggested in the docs, but the command still doesn't run.
Any help is much appreciated - thanks
My settings.json looks like:
"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.integrated.defaultProfile.windows": "zsh",
"terminal.integrated.profiles.osx": {
"zsh (login)": {
"path": "zsh",
"args": [
"reload -b"
]
}
},
I recently started working on vscode. I wanted to debug my C code. But the moment I am launching the debugger getting Error : Unable to start debugging. The value of miDebuggerPath is invalid.
I have my gdb installed on wsl . It's path is /usr/bin/gdb. I have copied same path to launch.json in miDebuggerPath.
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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
It should not throw the error and I should able to launch my debugger.
So this happened to me on WSL-Ubuntu. In my case gdb was broken because of unmet dependencies. Took a while to fix but once I reinstalled gdb properly in my WSL-Ubuntu, I finally got it working.
Installing gdb can be done on shell as
sudo apt-get install gdb
There can be multiple reasons why it could end up as broken, but once you fix gdb, vscode-debugging should be running. At the very least, you won't see that error popping.
I had the same problem, my solution was:
1. Change this section in launch.json
"miDebuggerPath": "/usr/bin/gdb",
for:
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",
2. Do you need to install in your PC MinGW, this is the link:
https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/
3. Next, open the MinGW then you install in the URL "C:/MinGW/bin" the gdb (select)
mingw32-gdb-bin
4. Enjoy the vs-code
it should be
"miDebuggerPath": "/usr/bin/gdbus",
If you're running under WSL, you should check where gdb is in your current distro to set your "miDebuggerPath" using
whereis gdb
in my case it was in
/usr/bin/gdb
but it could be somewhere else, that depends on what Linux distribution are you using with WSL
Could you try this:
sudo apt install binfmt-support
I am using VcXsrv, and this fixed all my installation problems, including chrome and GNU C++.
i had a similar problem ,this fixed. WINDOWS 10
QUICK ANSWER : try
1)C:\your compiler\bin\gdb.exe (paste your compiler path )
or
2)C:\TDM-GCC-32\bin\gdb32.exe for 32 bit compiler .(in my case)
(i tried to use opengl GLFW glad with 32bit tdm-gcc c++ compiler , i used a repo from OpenGL C++ template by vkphillia
but when i tried to run it in vs code using "run without debugging " option ,it showed the error "Unable to start debugging : The value of miDebuggerPath is invalid",
i copied my tdm_gcc compiler's bin path in midebugger path and it was like this ,
C:\TDM-GCC-32\bin\gdb.exe , but it did not remove the error then i checked for the gdb.exe application in my tdm gcc compiler bin where i noticed that there was no gdb.exe but a gdb32.exe file
I had the similar problem, running on linux.
Installing gdb fixed it.
When trying to build SASS, I'm getting the following error on Sublime Text 2. I've added the SASS build plugin from here https://github.com/jaumefontal/SASS-Build-SublimeText2
env: ruby_executable_hooks: No such file or directory
[Finished in 0.0s with exit code 127]
Not really sure what I should be doing here to troubleshoot this.
Thanks!!
The amount of negative votes tells me I need to add more information. The problem is I'm not quite sure what information I should be adding.
My SASS.sublime-build file inside /Library/Application Support/Sublime Text 2/Packages/SASS Build/
{
"cmd": ["sass", "--update", "$file:${file_path}/${file_base_name}.css", "--stop-on-error", "--no-cache"],
"selector": "source.sass, source.scss",
"line_regex": "Line ([0-9]+):",
"osx":
{
"path": "/Users/vskylabv/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:/usr/local/bin:$PATH"
},
"windows":
{
"shell": "true"
}
}
which ruby_executable_hooks
/Users/vskylabv/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks
The sass file being run is actually a script, with a hashbang line along the lines of #!/usr/bin/env ruby_executable_hooks (if it's not in sass, it's in another file being called). Sublime's environment is not necessarily the same as your command line environment, which is why you're getting the error message you're seeing. Open a terminal, and type
which ruby_executable_hooks
to find out the directory it lives in. Then, open Packages/SASS-Build/SASS.sublime-build:
{
"cmd": ["sass", "--update", "$file:${file_path}/${file_base_name}.css", "--stop-on-error", "--no-cache"],
"selector": "source.sass, source.scss",
"line_regex": "Line ([0-9]+):",
"osx":
{
"path": "/usr/local/bin:$PATH"
},
"windows":
{
"shell": "true"
}
}
If you're on OS X, change the "path" line in the "osx" section to:
"path": "/full/path/to/ruby_executable_hooks:/usr/local/bin:$PATH"
and save the file. Note the full path should just be the directory containing ruby_executable_hooks - for example, /Users/MichaelT/.rvm/gems/ruby-2.0.0-p247/bin.
Good luck!
You need to run the following command in the Terminal to refresh the executable-hooks to the latest version. That should take care of the issue.
sudo gem install --user-install executable-hooks
I had the same problem using an rvm installed version of sass in NetBeans 7.4.
You should switch to system ruby to avoid the rvm issues.
rvm use system
Now, check that you have sass in your system ruby:
gem list sass
Then if no sass, install the sass gem:
gem install sass
On OS X this will put sass into /usr/bin/sass
/usr/bin is in your path already so your sublime-build config should work.
I've tried different settings like simply:
{
"cmd": "rubocop '$file_name'"
}
I've also tried setting the path, etc:
{
"cmd": "rubocop '$file_name'",
"path": "~/.rvm/bin",
"selector": "source.rb",
"working_dir":"$project_path"
}
For both I get an error message along the lines of:
[Errno 2] No such file or directory
[cmd: rubocop 'configurer.rb']
[dir: /home/rafal/Documents/Projects/configurer]
[path: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games]
[Finished]
and:
[Errno 2] No such file or directory
[cmd: rubocop 'configurer.rb']
[dir: /home/rafal/Documents/Projects/configurer]
[path: ~/.rvm/bin]
[Finished]
respectively. I have followed some of the tutorials I've found online as well as some of the answers here at StackOverflow but no luck. Any ideas on why this is happening? What is the correct and working way of running a Ruby Gem upon a currently open file? The Gem Rubocop is definitely installed.
I made the custom build work on SublimeText2 with
{
"env": {
"PATH":"${HOME}/.rvm/bin:${PATH}"
},
"cmd": ["rvm-auto-ruby", "-S", "bundle", "exec", "rubocop -n ${file}" ],
"selector": "source.ruby"
}
Note that the -n option of rubocop was introduced 5 days ago in the repo (after the 0.6.1 release), so it probably won't work if you don't use the rubocop from the git repo. Until 0.6.2 is released, it will display weird chars in the output, but at least it will work.
I'm trying to use Sublime Text 2s build system to run a Grunt task. I have no issues using Grunt within Terminal. My setup works well on my Windows machine but my Mac hates it.
This is my .sublime-build configuration:
{
"selector": "grunt.js",
"working_dir": "${project_path}/js",
"windows": {
…
},
"osx": {
"cmd": ["grunt", "--no-color"]
}
}
And the output returned is:
[Errno 2] No such file or directory
The working directory and path returned are correct. My software versions are:
OSX 10.8.2
Node 0.8.9
NPM 1.1.68
Grunt 0.3.17
Sublime Text 2.0.1
Please save me any more frustrated Googling!
Make sure grunt is in your path with sublime (it can be different then your terminal path). To find the path type: npm bin -g. You can set the path in your sublime-build config:
{
"selector": "grunt.js",
"working_dir": "${project_path}",
"path": "/usr/local/bin",
"osx": {
"cmd": ["grunt", "--no-color"]
}
}
Just a nitpick, set the working_dir to the base project path. Not important as grunt will find up until it reaches a gruntfile but that will find the gruntfile slightly faster ;)