I see in a lot of the tutorials and how to pages, they use the following, or something similar
ruby C:\test.rb
Which would parse test.rb to the interpreter and ... execute the script. But how is this done on Windows? Ruby isn't a recognized internal command (as per the shell output)?
I know how to do all these things on Linux, and its as simple as... alas Windows is completely confusing at times :)
Your best bet is going to be to add the path to the Ruby executable to your Environment Variables:
Right click on 'Computer' in Windows.
Click 'Properties...'
Select the 'Advanced' tab.
Click 'Environment Variables'
Find 'Path' in the list and click edit
Add C:\Ruby\bin; (or wherever you installed Ruby to) to the end of the string
In Windows, you could add the directory which contains ruby.exe to the System-Variable Path, then the above should work. See here for a small tutorial (btw. the directories are separated by ; (semicolon), not by : as in UNIX).
Also possible
cd \Path\To\Ruby\Interpreter
ruby.exe C:\test.rb
since . (the current working directory) is always part of Path.
Related
Context: I am a total command line noob. I am following this tutorial to get started on Git: https://www.youtube.com/watch?v=QqP7YZlZEOo. I am a windows user.
I have just installed Git and added PyCharm as my default text editor. I then opened the "Git Bash" at the end of installation. I successfully made the new directory "git-work-flow", just as he did in the video. I then used "cd" to move to the new folder. Where I lose him is when he opens the new directory in his default text editor, Sublime.
I cannot find the corresponding command to open it with my default editor, PyCharm.
PyCharm documentation says use "PyCharm .", but this does not work. Neither does 'pycharm64 .' or any other combination or permutation of answers shotgunned all over this site. Some have mentioned some extra set-up required but no documentation is found that I can follow, being a total noob.
How can I do this?
One interpretation of the question title is "What is (or how to find) the current directory in git bash?". Linux syntax is likely to be unfamiliar to long-time Windows users, so you may be interested in the command:
$ explorer .
This opens Windows Explorer pointing to the current directory (i.e. wherever you happen to be in bash).
The "." at the end means "current directory" so you just have to have a program which accepts paths as parameter, e.g. pycharm.
If it doesn't work it means probably it's not in the path, as Poojan suggested, so either one can:
type the full path to the executable for it, e.g. something like (double quotes actually necessary because of space in path)
"c:\program files\pycharm\bin\pycharm64" .
or put the path in the PATH environment variable, e.g.
Startmenu->run->SystemPropertiesAdvanced
Environment variables
double click PATH
add the path, e.g. c:\program files\pycharm\bin\pycharm64
now I'm currently using Visual Studio Code and I wanted to make the terminal use babun instead of the default cmd.exe
In fact, I have already managed to do that in theory - the problem is that, unlike with cmd.exe, the directory that I'm in upon starting the terminal is no longer the currently open project, it's just simply /home/myusername (i.e. a path in babun's directory tree).
This kinda sucks, since I don't really want to navigate to my directory every time.
Next, I also found out how to tell babun (in my case, zsh.exe) to use a default directory such as C:/ by adding cd /cygdrive/c to the end of .zshrc - Unfortunately, that's not what I want either, since I don't want babun to always use the same directory.
Now I figured that, seeing as this would be the most comfortable option with VSC*, there might be some console argument that tells zsh.exe to use a specific directory. Sadly, I couldn't find anything, hence this question.
Weirdly enough
Anyone know how to help me out? Appreciate the help :)
*VSC allows you to specify the path to your shell, as well as an array of arguments that will be passed.
You could place your directory into a cmd file and run it as a shell:
d:
#rem note that's important to change the drive 'permanently'
cd d:\home
zsh.exe
And then specify this cmd file as shell to invoke.
Open the desired directory in a file explorer, right click, then select Open Babun here.
Babun currently does not natively support a command line parameter specifying the directory to launch in.
However, there is a pull request in the Babun GitHub which solves the issue. Unfortunately, it doesn't seem to be likely to be accepted anytime soon, though.
To gain access to the feature manually, check out the pull request.
I'm trying to make my data files "clickable" like a MS Word document. When a user clicks on a file on the desktop with a ".vr" extension, I want it to execute my Ruby script, and pass the file name as a parameter.
I've created a mime type, "text/vr" with the ".vr" extension, and when I click the file, "text.vr" on the desktop, it attempts to run the command:
$vr test.vr
This command fails because it tries to use an old version of Ruby. The problem is that Ubuntu uses a different environment when it launches a program from the desktop instead of the prompt.
I use RVM, and it works perfectly when I write programs in the terminal. However, when I click on the file to launch the vr script, RVM isn't used. I need to find a way to make RVM load when a file is clicked.
What's going on here? What environment file is loaded when you execute a file from the desktop? ~/.bashrc? ~/.profile? How can I make it so my whole computer always finds RVM?
Thanks,
Eric
There are few ways, the environment for desktop is loaded from .profile, add one of this:
source $HOME/.rvm/environments/ruby-1.9.3-p327 #OR:
source $HOME/.rvm/environments/default
to load specific ruby.
sometimes it might not work with sourcing, then adding content of the default file to .profile should work:
cat $HOME/.rvm/environments/default >> ~/.profile
It is required to relogin / restart to apply the changes.
I have a shell extension installed into the filesystem by adding ".{CLSID}" to the folder name. The Shell Extension is like the .zip extension (allowing you to see files). Explorer handles it fine, but how do I get other program to recognize the sub files/folder (programs like command shell). I navigate to the directory with the shell and it shows the empty folder (also, it doesnt strip away the clsid). Is there some way to implement that functionality? Do I have to install the extension in a different way?
Thanks!
chacham15
If I remember correctly, there is no documented way to add an extension to the windows cli shell (cmd.exe).
There is an add on shell for windows called 4NT that is extensible.
That said, you'll still end up writing scripts if I understand your question correctly.
I installed Erlang 13B and tried to follow the tutorials.
Every time I get to c(tut), I get an error instead of (ok, tut), so it seems like there are no modules installed. Can anyone point me in the right direction?
I've tried Emacs but I don't really know how to use it and haven't even got close to getting the Erlang mode working. For instance, where do I type:
(setq load-path (cons "C:/Program Files/erl5.6.2/lib/tools-<ToolsVer>/emacs"
load-path))
(setq erlang-root-dir "C:/Program Files/erl5.6.2")
(setq exec-path (cons "C:/Program Files/erl5.6.2/bin" exec-path))
(require 'erlang-start)
For c(tut) to work, there has to be a tut.erl file in the current directory.
This is easy to accomplish if you start the Erlang interpreter from the command line, as is common on systems like Linux and OS X, but this isn't the usual pattern on Windows. When you start Erlang on Windows from the icon in the Start menu, the current working directory defaults to the location of werl.exe, which isn't where your tut.erl file is.
To make your command work as expected, you have to change your working directory to be the location of tut.erl after starting the Erlang shell. If tut.erl is on the Desktop, the command will be something like this on Vista or Windows 7:
cd("c:/Users/myname/Desktop").
(Yes, you have to use forward slashes. Backslashes are special in Erlang strings.)
On Windows XP and older, your Desktop folder is buried much deeper. It might be simpler to put werl.exe in the system PATH and use the command line on such systems.
It isn't necessary, but you might want to consider installing Cygwin. Its Bash shell will give you a more Linux or OS X like environment, which will help you work with other tutorials that are structured for those OSes.
After you install Erlang open the shell and do:
1> pwd().
C:/Program Files/erl5.7.1/usr
ok
2>
Assume you have a file; "tut.erl" on your desktop. Content might look like this:
-module(tut).
-compile(export_all).
hello_world() ->
hello.
You must change the path of the current working directory to the desktop first (or where ever you want to do the compile). Like this perhaps:
2> cd("F:/Desktop").
F:/Desktop
ok
3>
Then you can perform the compile.
3> c(tut).
{ok,tut}
4>
Then test the module
4> tut:hello_world().
hello
5>
More info refer to the documentation here: Erlang official documentation
More info on the shell, look here: Shell module
Hope this gets your started.
You can also create an initialization file named .erlang under YourErlangInstallationPath\usr\
the content of the file should look something like this;
io:format("consulting .erlang in ~p~n" ,
[element(2,file:get_cwd())]).
%% Edit to the directory where you store your code
c:cd("O:/Erlang.Umut").
io:format("Now in:~p~n" , [element(2,file:get_cwd())]).
it will automatically change the path to your working folder. (Obviously, my path is O:/Erlang.Umut, you need to replace it with yours.)
No need to change folders every time you launch console. Console will be able to reach your erl files directly.
I recently tried Erlang on windows.
use the console window to make sure the text editor you are using is giving your files the correct extension ie. filename.erl and not filename.erl.txt like mine was!
when I saved my files in notepad it added .txt so I saved in unicode. fixed
If you are still getting "tut:erl:none: no such file or directory", the file name is wrong. If you open a Windows command prompt and move to your desktop and type "dir" you will see that tut.erl is really named tut.erl.txt. type "ren tut.erl.txt tut.erl" and now your compile will work.
When werl's current working directory is same as the file to be compiled, the filename is given as an argument without the whole path.
Otherwise, for eg. Assuming tut.erl is placed at C:\ErLang tutorials, one may try compiling as,
c("C:\\ErLang tutorials\\tut").
Note:
Without double quotes the : causes syntax error
The backslash is given using escape sequence