Can't run ghci in Terminal - haskell

every time I type ghci into the terminal or a command I would execute through ghci it tells me zsh: command not found: ghci.
I'm super new to this and don't really know what to do?
Commands like cd and so on that are for the items on my Mac work just fine.

It sounds like bash was your shell when you installed GHC, but Apple later switched you to zsh. The problem is that it was only added to your path for bash. Look for a line in ~./bashrc or ~/.bash_profile that looks something like this:
[ -f "${GHCUP_INSTALL_BASE_PREFIX:=$HOME}/.ghcup/env" ] && source "${GHCUP_INSTALL_BASE_PREFIX:=$HOME}/.ghcup/env"
It might not look quite like that, but the important part is the reference to .ghcup/env. Once you find that line, copy it and add it to the end of ~/.zshrc. Then restart your shell and try again.

Here's the GUI version of it.
Open Ghcup GUI with the command
ghcup tui
You would notice something like this
GCHUP GUI:
For me when the ghc or ghci command was not working, there was a single tick beside GHC option.
Go to that option and press s to set. It worked for me.

You could try wirte . ~/.ghcup/env in the ~/.zshrc file. Another thing is restarting the terminal.

Related

Installing GHCi requires to change my path to use in terminal

[![I'm trying to write Haskell code in a text editor then run it with GHCi in my terminal. I successfully installed GHCi (I think), and am trying to run a command to run some code I wrote, but I there is no command found for ghci or ghc. Do I need to change my terminal path to where I downloaded/installed GHCI? Also if I change the path will it permanently change my starting path in terminal? Here's the last thing my terminal says. I've also tried stack ghci.
EDIT
My error is that the commands are not found when I run them in terminal.
I installed everything by running this command in my terminal and continuing to type YES when prompted.
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
The contents of /Users/Jack/.ghcup/env is
export PATH="$HOME/.cabal/bin:/Users/Jack/.ghcup/bin:$PATH"
Note to others reading this: I recommended ~/.profile instead of ~/.bashrc because I know from the original question (before it was revised) that the OP is using a Mac (more info on bash on Macs).
Try running these three commands in order in your terminal:
echo 'export PATH="$HOME/.cabal/bin:/Users/Jack/.ghcup/bin:$PATH"' >> ~/.profile
. ~/.profile
ghci
What this will do is modify your PATH environment variable as necessary so that your shell can find the ghci program. It will also store this modification in your ~/.profile so your PATH will have the correct value next time you log in.
Also if I change the path will it permanently change my starting path in terminal?
The PATH environment variable is not related to the initial working directory of your terminal. So no, your terminal's "starting path" will not be changed.
Just write . ~/.ghcup/env in the ~/.zshrc file. Another thing is restarting the terminal.

Want to understand what's going on with linux command

I am installing a virtualenv and want to understand what's going on.
$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
- I understand curl fine
$ python virtualenv.py my_new_env
- Understand this, too
$ . my_new_env/bin/activate
- Here's where I get lost. What is the period doing here?
(my_new_env)$ pip install ...
- What does it mean to have the parentheses here? Does this use tell me I'm in a folder?
The dot is a command that means to read and execute the contents of the given script in the current shell (normally running a shell script runs it in a new process.) Evaluating the script in the current shell can change the environment variables of the current shell, so the behavior of subsequent commands is affected.
I don't know for sure about the parentheses, but I don't think they're meant to be syntax you type. As they come before the '$' prompt, perhaps that's literally what you'll get as your new prompt after running the activate script, to show you that your environment has been changed?
The dot is essentially an "execute" command — execute the commands in my_new_env/bin/activate as though they were typed into your prompt, essentially.
The parentheses shown in the prompt (at least in the tutorial instructions) then indicate that you're typing commands in your new virtual environment, and not in your original (real) environment.

How do I run an interpreter with command history support?

I know there is a way to run an interactive console with command history support (even though the program does not inherently support it). However, I don't remember the command. Can anyone help me?
Try ledit.
E.g.
$ ledit mycommand
Install the package rlwrap and run it like
$ rlwrap foo
to get command line history for the command foo.

How to compile from gVim on Windows with GCC from Cygwin and then run the program?

I've been working at this all morning and I still can't find a way to easily bind a key to compile my program from the Windows version of gVim using the Cygwin GCC, and then run it. I'm kind of a novice to Bash scripting, and I haven't been able to make it create the .exe in the home directory (C:/cygwin/home) and then run it.
What I have so far:
map <F4> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc /home/%:t && cd C:/cygwin/home && ./a.exe"
endfun
This would work all well and good, except that when I go to the home directory, the a.exe is not there. Compiling using gcc from the bash script .bat in cygwin works fine... but not from gVim.
Thanks for all help in advance.
check this plugin.
it seems to be what you want.
I haven't tested it though.
For mono-files projects, you don't need any makefile. Thus, as long as gcc and make are in your $PATH, and you are in the directory where the current source file comes from, you "just" have to type:
:update
:make
If your program has no error, a simple !./%< will do.
Otherwise, you may then have to execute a :copen to see compilation errors. If you have any, you'll notice some pathnames in *nix format. Unfortunately (g)vim-win32 is unable to understand them. That where my old cygwin compiler plugin skeept told you about comes into play. In order to support any compilation-like program (and not just make), it evolved into BuildToolsWrapper -- its installation will require lh-vim-lib, and may be a few other plugins of mine (system_tools, searchinruntime).
With it, just do once a :BTW add cygwin before you play with :make, or even :Make that BTW defines. This new command will do a :update! before calling :make with a automagically determined target. NB: BTW maps Make and the execution of the current project executable to <F7>and to <C-F5>.
PS: if you have have several files in your project, define a Makefile, and play with :make, that's all.
PPS: you may also be interested into cyg-wrapper.sh that helps to correctly open gvim-win32 from cygwin shell.
Basically, when gcc runs it produces binary right in the working directory. If you want to place the output binary in a different directory you have to pass the -o options. So the command should be either of these:
exec "!gcc -o C:/cygwin/home/a.exe /home/%:t && cd C:/cygwin/home && ./a.exe"
exec "!cd C:/cygwin/home && gcc /home/%:t && ./a.exe"

Screen and Cygwin: no tab completion?

I'm having some problems working with my development environment. Specifically, after I invoke the screen utility from within Cygwin I lose the ability to do tab completion. Before I invoke screen however tab completion works just fine.
I messed around with setting different values for the TERM env variable (VT100, xterm etc) but without success. It must be something trivial but I have no idea anymore. Does StackOverflow have any suggestions for me?
when you issue 'screen' from inside cygwin it might put you in another shell like /bin/sh instead of /bin/bash (and bash is where you're getting the tab completion from).
To fix the problem you could edit your .screenrc file (found in your home directory) and add in this line:
shell bash
Then try running screen again and you should see tab completion work within this new window.
The problem is that bash needs to be run as a login shell in order to have tab completion in the default cygwin setup. If you run bash in a cygwin bash you won’t have tab completion either. To set screen to run bash in login mode, add this line to your ~/.screenrc file:
shell -bash
I had a similar problem with git autocompletion not working when using screen on a linux machine, but wasn't due to a different shell. I fixed it using this question: Git autocomplete in screen on mac os and doing the following:
Get the git autocompletion script
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -OL
why would you want that hanging around?
mv git-completion.bash .git-completion.bash
add this line to your ./bashrc
source ~/.git-completion.bash
Then in your terminal
source ~/.bashrc
That worked for me.
(I imagine after three years you've probably solved your problem, but I hope this helps someone else)

Resources