简体   繁体   English

-bash: ghci: command not found (Haskell interactive shell, Haskell 安装)

[英]-bash: ghci: command not found (Haskell interactive shell, Haskell installation )

edit: I ended up upgrading to macOS Catalina yesterday and replacing bash with zsh.编辑:我昨天升级到 macOS Catalina,并用 zsh 替换了 bash。 One thing that should be noted is that the stack command worked previously, but despite all the tinkering not ghci After deleting all the files that had anything to do with Haskell, I retried running curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh应该注意的一件事是stack命令以前工作过,但尽管所有的修补都不是ghci在删除所有与 Haskell 有关的文件后,我重试运行curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh This second time there was an error with the command line tools so I had to install them manually with xcode-select --install . curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh第二次出现命令行工具错误,所以我不得不使用xcode-select --install手动安装它们。 After rerunning the curl, I added the path to the environmental file to my zsh profile manually with: . "$HOME/.ghcup/env"\重新运行 curl 后,我手动将环境文件的路径添加到我的 zsh 配置文件中: . "$HOME/.ghcup/env"\ . "$HOME/.ghcup/env"\ echo '. $HOME/.ghcup/env' >> "$HOME/.zshrc" . "$HOME/.ghcup/env"\ echo '. $HOME/.ghcup/env' >> "$HOME/.zshrc" echo '. $HOME/.ghcup/env' >> "$HOME/.zshrc" Here is the content of the env file: export PATH="$HOME/.cabal/bin:/Users/agnel/.ghcup/bin:$PATH" Now everything seems to be working (I never reinstalled stack, but I think I might leave that to the side while I learn the basics of the language). echo '. $HOME/.ghcup/env' >> "$HOME/.zshrc"这是环境文件的内容: export PATH="$HOME/.cabal/bin:/Users/agnel/.ghcup/bin:$PATH"现在一切似乎都在工作(我从未重新安装堆栈,但我认为在学习语言基础知识时我可能会把它放在一边)。

I installed the Haskell Platform yesterday but am having a hard time getting it to work correctly.我昨天安装了 Haskell 平台,但很难让它正常工作。

The firsts steps I did are:我做的第一步是:

  1. curl -sSL https://get.haskellstack.org/ | curl-sSL https://get.haskellstack.org/ | sh
  2. curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

On step 1. the instructions said to append /Users/.../.local/bin the PATH variable (which I did in /etc/paths . On step 2, the script was supposed to pop up a dialog box (and didn't) when installing the necessary command line tools. It also said to rerun the script once complete (which I did). The script also said I should adjust my PATH variable, and source /Users/.../.ghcup/env in my shell configuration. It asked to this automatically but failed having not found the ~/.bashrc File. (I read that on Mac in contrary to linux, only .bash_profile is loaded upon opening of a terminal window so I adjusted the path variable there manually. I've spent forever messing around with the path variables and every time I try and run "$ ghci" I get the same -bash: ghci: command not found error message. If anyone has a solution to this problem I would be very grateful for an answer. If not, could someone with a working distribution of Haskell on their computer s在步骤 1 中,说明对 append /Users/.../.local/bin PATH 变量(我在/etc/paths中所做的)说。在步骤 2 中,脚本应该弹出一个对话框(并且没有't) 在安装必要的命令行工具时。它还说一旦完成就重新运行脚本(我这样做了)。脚本还说我应该调整我的 PATH 变量,和 source /Users/.../.ghcup/env在我的 shell 配置中。它自动询问但没有找到~/.bashrc文件。(我在 Mac 上读到与 linux 相反,只有.bash_profile在打开终端 window 时加载,所以我调整了路径变量在那里手动。我一直在弄乱路径变量,每次我尝试运行“$ ghci”时,我都会得到相同的-bash: ghci: command not found错误消息。如果有人能解决这个问题,我会非常感谢您的回答。如果没有,有人可以在他们的计算机上使用 Haskell 的工作分布吗? how me what their path variables look like?我怎么知道他们的路径变量是什么样的? Thanks!谢谢!

After installing the Haskell platform for the first time on a new mac with Catalina, I also got第一次在新的 mac 上用 Catalina 安装 Haskell 平台后,我也得到了

~> ghci
zsh: command not found: ghci

What worked in my case was to use, instead of the plain ghci ,在我的案例中有用的是使用,而不是普通的ghci

stack ghci

To get back the familiar behaviour, I created in my homedirectory a file named .zshrc containing为了恢复熟悉的行为,我在主目录中创建了一个名为.zshrc的文件,其中包含

alias ghci='stack ghci'

If you open a new terminal, this file will automatically be executed.如果你打开一个新的终端,这个文件会自动被执行。

I'd be interested to know if there is another solution.我很想知道是否有其他解决方案。

A simple solution would just be to restart your terminal and you are good to go.一个简单的解决方案就是restart your terminal ,您可以使用 go。

Check if the ghcup command is working or not.检查ghcup命令是否正常工作。

  1. If not, make sure the .zshrc file has command for execution of ghcup.如果没有,请确保 .zshrc 文件具有执行.zshrc的命令。 It should look something like this -它应该看起来像这样 -

[ -f "/Users/myusername/.ghcup/env" ] && source "/Users/myusername/.ghcup/env" # ghcup-env [ -f "/Users/myusername/.ghcup/env" ] && source "/Users/myusername/.ghcup/env" # ghcup-env

  • If the file exists, simply restarting terminal will work.如果该文件存在,只需重新启动终端即可。
  • If it is still not working, set GHC as default using ghcup - follow this如果它仍然不起作用,请使用 ghcup 将 GHC 设置为默认值- 按照操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM