如何将目录添加到PATH?

编程入门 行业动态 更新时间:2024-10-24 13:27:36
本文介绍了如何将目录添加到PATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

总而言之,我正在尝试使用LetsEncrypt向自己颁发SSL证书,并且最近安装了rbenv来简化此过程.安装rbenv后,我检查是否使用

Long story made short, I am trying to issue myself an SSL certificate using LetsEncrypt, and have recently installed rbenv to make this process easier. After installing rbenv, I check to see if everything checks out using

curl -fsSL github/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash

我比得到此消息说没有安装任何版本的ruby.尝试使用命令

I than get this message saying that there are no versions of ruby installed. After trying to install ruby using the command

"rbenv install 2.3.1"

我收到此错误

rbenv: no such command `install'

是因为我的rbenv垫片的路径不在我的PATH变量中吗?如果是这种情况,如何将目录添加到PATH变量中?我知道您必须将它们添加到bash_profile文件中,但是不确定在该文件中我需要添加什么内容以及需要添加什么内容.

Is it because the path to my rbenv shims aren't in my PATH variable ? If this is the case how do I add directories to my PATH variable ? I know you have to add them to your bash_profile file, but am not sure where in this file I need to add something, and what I need to add.

〜/.bash_profile

~/.bash_profile

# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs function letsencrypt_webfaction { PATH=$PATH:$GEM_HOME/bin GEM_HOME=$HOME/.letsencrypt_webfaction/gems RUBYLIB=$GEM_HOME/lib ruby2.2 $HOME/.letsencrypt_webfaction/gems/bin/letsencrypt_webfaction $* } eval "$(rbenv init -)" PATH=$PATH:$HOME/bin export PATH export PATH="$HOME/.rbenv/bin:$PATH"

推荐答案

在编辑配置文件时始终要小心.

Always be careful when editing the profile.

最好先备份

  • 切换到主目录: cd
  • 列出隐藏文件: ls -la .bash*
  • 制作.bash_profile的备份副本: cp -p .bash_profile .bash_profile.bak
  • 检查当前路径:echo $PATH
  • 检查ruby是否在PATH中:which ruby
  • 检查红宝石版本:ruby --version
  • switch to home directory: cd
  • list hiden files: ls -la .bash*
  • make a backup copy of .bash_profile: cp -p .bash_profile .bash_profile.bak
  • check the current PATH: echo $PATH
  • check if ruby is in the PATH: which ruby
  • check the ruby version: ruby --version

我不确定您的.bash_profile中该功能的来源:function letsencrypt_webfaction()

I am not sure where this function is comming from in your .bash_profile: function letsencrypt_webfaction()

使用:作为分隔符,并在PATH中添加新目录new_dir,使用$PATH保留实际PATH的内容,然后导出新PATH:

Use : as a separator and add a new directory new_dir to your PATH, use $PATH to keep the contents of the actual PATH, then export the new PATH:

PATH=$PATH:/new_dir:/new_lib export PATH

验证终端是否需要该PATH:echo $PATH

Verify if the PATH is what you need from the terminal: echo $PATH

我个人认为应该直接备份.bash_profile.用#注释该函数的3行以及PATH出现的其他行,并添加以下内容:

Personaly I sugest making a backup of .bash_profile as it is. Comment out with # the 3 lines for the function and the others where the PATH appears and add this:

export RUBYLIB=$HOME/lib export GEM_HOME=$HOME/gems export PATH=$HOME/bin:$PATH:

在此之后,请检查上方的小圆点,看看您是否拥有所需的红宝石版本.

After this please check the bulet points above and see if you have the ruby version you expect.

更多推荐

如何将目录添加到PATH?

本文发布于:2023-05-31 10:06:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/389569.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   目录   PATH

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!