How to find a valid path to julia.exe - path

I try to use julia-1.6 with VScode, but I cannot find a path to the executable.
When I try to change the working directory via the julia prompt to the executable, I get an error message saying it's not a directory:
julia> cd("/Users/jjdegruijter/bin/julia")
Can anybody tell how to do it properly?

To get the path to your Julia executable, from the REPL, do:
joinpath(Sys.BINDIR, "julia")
You can start a REPL by just running julia from the terminal, or by pressing Alt-J Alt-O in VS Code (you can also instead type Ctrl-Shift-P, then choose Julia: Start REPL from that list).
Or, you can also directly run the above command from the terminal without starting a REPL: julia -e 'println(joinpath(Sys.BINDIR, "julia"))'.
If you just want to change working directory to the directory containing the executable (though I'm not sure why you'd want that here):
cd(Sys.BINDIR)

Related

Can't use commands from ipython or julia repls with zsh

When I try to run a shell command in ipython or the julia repl it just says
shell> ls
zsh:1: command not found: ls
Not sure if it matters, but I have my path set in zshenv instead of zshrc so that emacs shell works.
Any ideas?
Edit:
I'm on macOS 10.14.6
For Julia, The shell> REPL prompt does in fact use a shell to execute its commands (on non-Windows systems). It effectively does something like run(`$shell -c ls`), and for most shells (including zsh) this means "non-interactive" mode and limits the number of init files that get loaded. You want to make sure your shell is working in this mode; I'd guess that if you type zsh -c ls at your terminal it'll be similarly broken.
Alternatively, you can customize which shell Julia uses through an environment variable. Setting JULIA_SHELL=/bin/sh is probably a safe bet — Julia uses that environment variable if it is set, otherwise it uses SHELL, and finally it falls back to /bin/sh if neither is set.
I'm not as familiar with ipython, but I'd wager it's doing something similar.

Why use $PATH and what is it

I'm sort of new to programming (not really, but I'm still learning - aren't we all?). Although I know Java and Python and sort of know C, C++, JS, C#, HTML, CSS, etc. (and I can navigate pretty well in the terminal), I am not familiar with what $PATH is in the terminal.
I've been using the Linux terminal and Mac terminal much more frequently than I used to (if I even did at all two years ago), and I know for python, it wants you to "export" its path like PATH=\path\to\python\bin:${PATH}\ export PATH. However, I don't even know what it does. I tried to find out, but all I could find were people saying "export this path and export that one."
So, what is it and why use it? I understand that (if you do it for Python), it basically makes 'python' (or 'python2' or 'python3') a variable, but I just don't understand the concept of what it is.
man bash describes it as:
PATH
The search path for commands. It is a colon-separated list of
directories in which the shell looks for commands (see COMMAND
EXECUTION below). A zero-length (null) directory name in the
value of PATH indicates the current directory. A null directory
name may appear as two adjacent colons, or as an initial or
trailing colon. The default path is system-dependent, and is
set by the administrator who installs bash. A common value is
/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin'.
When you run a command, like python, the operating system tries to find the python program in the list of directories stored in PATH.
Suppose your PATH is /usr/local/bin:/foo:/bar:/baz:/usr/bin. When you try to run the python comamnd, the operating system will look for an executable named python in those directories in order. On Linux, you can watch it do this with the strace command:
$ PATH=/usr/local/bin:/foo:/bar:/baz:/usr/bin strace -f /bin/bash -c 'python --version' 2>&1 | grep 'stat.*python'
stat("/usr/local/bin/python", 0x7fff98b63d00) = -1 ENOENT (No such file or directory)
stat("/foo/python", 0x7fff98b63d00) = -1 ENOENT (No such file or directory)
stat("/bar/python", 0x7fff98b63d00) = -1 ENOENT (No such file or directory)
stat("/baz/python", 0x7fff98b63d00) = -1 ENOENT (No such file or directory)
stat("/usr/bin/python", {st_mode=S_IFREG|0755, st_size=4864, ...}) = 0
As soon as python is found in /usr/bin/python, the search stops, and the program runs.

Run script from dock in Mac OS X

I am developing web applications using Ruby on Rails and Sublime Text 3 on OS X 10.8.4. I recently installed the package RubyTest. The tests only work when Sublime is launched using the command
subl
in terminal. Otherwise I get the error message:
/bin/sh: rspec: command not found
I think that's meant to be the case; that's implied in RubyTest's readme file on github.
However I'd like to retain the ability to launch from the dock. Is there a way I can do this?
Unfortunately, OSX applications do not pick up on your $PATH variable set in Terminal. To change the internal PATH settings in Mountain Lion (this method hasn't been tested with previous versions, although it should work), you'll need to edit /etc/launchd.conf:
Make sure you have admin privileges.
Open Terminal or your favorite substitute and see if there's anything in the file /etc/launchd.conf:
cat /etc/launchd.conf
If you get an error like
cat: /etc/launchd.con: No such file or directory
then continue with the next step. If the cat command does display some content, copy it to the clipboard.
Create a new text file with the following content, modified to fit your needs:
setenv PATH /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/Users/YourUserName/bin:/path/to/gems/bin
If the cat command displayed some content in the previous step, paste it into the new file before the setenv PATH command. If it already contains a setenv PATH command, just modify it to add the directories you need, such as /path/to/gems/bin
Save the new file in your home directory (/Users/YourUserName) as launchd.conf.
Go back to Terminal and enter:
sudo mv ~/launchd.conf /etc
to use admin power to move the new file to /etc, replacing anything that was there before. Depending on your previous usage of the sudo command, you may get a short "be careful doing what you're doing" message, but either way you'll need to enter your password. /etc is not directly accessible through the Save dialog unless you're a real power user and know how to get around OSX's file system restrictions.
Reboot your computer
And you should be all set. If you're interested, launchd and launchctl use the csh/tcsh syntax, so you can't use the bash/zsh export PATH=/usr/local/bin:... format.

rubys> cd command not working in command line

I'm just getting into ruby and am trying to execute a walkthrough from Sam Ruby's Agile web development.
I've created a directory using mkdir work
Next i'm instructed to open a terminal and type rubys> cd work
The error I'm getting reads:
No command 'rubys' found, did you mean:
Command 'ruby' from package 'ruby' (main)
rubys: command not found
Can anyone inform me of what I'm doing wrong?
I've also tried changing from ~ to the work directory before entering my command.
In this book, rubys> is a command prompt, much like you have C:\> in the Windows terminal.
Ignore that first bit and everything should start working.
I guess you're doing it wrong.
mkdir work
creates a directory called "work". It has nothing to do with Ruby.
cd work
will then change into that directory. Forget about the rubys>.

where is my java file?

I'm using ubuntu and I call gedit by using this command:'sudo gedit filename.java'. I'm newbie in ubuntu so now I can not located that file. Ah I'm using windows XP and ubuntu and I have three disk C,D and E in windows XP the fourth disk for ubuntu is not display in windows XP. Can anyone show me where I can find my file? Thank you very much!
Try looking up the command "find". It will locate files.
The next time you need to find a file and you don't know where it is, just use the locate program included with Ubuntu. Sure, your file most likely won't show up immediately in the slocate database, but it's a really good searcher.
Also, the command line and the run prompt assume that the starting point, that is, the current working directory is always "~" unless you've set it differently. That means that all files and paths are relative to your home folder: /home/username for a user and /root for the root user.
Finally, you do not need to use the sudo command for writing code in your own home directory, and thus you can just stick with gedit filename.java. However, if you ever do need to use a graphical application with root/superuser privileges, use gksu for GTK apps and kdesu for KDE apps. sudo is for when you are running an program or need elevated privileges in a terminal.
Type "man find" into the terminal to get a description of how to use the command. But first place I'd look is the home folder. Open up the terminal and type "~" without quotes.
Open a terminal again ( from where you initially typed sudo ) and type ls -l you have to find it there.

Resources