首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过powershell在Windows 10上安装时Argo CD CLI错误

通过powershell在Windows 10上安装时Argo CD CLI错误
EN

Stack Overflow用户
提问于 2022-01-23 12:58:11
回答 1查看 604关注 0票数 0

我试图在我的windows 10 PC上安装ArgoCD CLI,方法是按照网站上的命令替换版本,但收到以下错误。它似乎不喜欢+操作符?有人能帮忙吗?

PS C:\Users\dell.docker> $url = "https://github.com/argoproj/argo-cd/releases/download/“+ v2.2.3 + "/argocd-windows-amd64.exe"

代码语言:javascript
复制
At line:1 char:66
+ ...  = "https://github.com/argoproj/argo-cd/releases/download/" + v2.2.3  ...
+                                                                  ~
You must provide a value expression following the '+' operator.
At line:1 char:67
+ ... ps://github.com/argoproj/argo-cd/releases/download/" + v2.2.3 + "/arg ...
+                                                            ~~~~~~
Unexpected token 'v2.2.3' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ExpectedValueExpression
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-23 14:39:15

您必须引用版本号:

代码语言:javascript
复制
$url = "https://github.com/argoproj/argo-cd/releases/download/" + 'v2.2.3' + "/argocd-windows-amd64.exe"

当然,您也可以首先使用一个引号字符串,由于使用了),如果版本号是通过变量提供的,它甚至可以工作。

代码语言:javascript
复制
$version = 'v2.2.3' # Quoting is required here too - '...' is a verbatim string
$url = "https://github.com/argoproj/argo-cd/releases/download/$version/argocd-windows-amd64.exe"

它似乎不喜欢+操作符

问题不在于+运算符,而是您打算使用的字符串文本-- v2.2.3 --没有引用。

运算符在PowerShell (表达式模式)中的表达式上下文中操作,在表达式中,所有字符串文字都需要引用。

相反,只有当您将参数传递给命令(参数模式)时,才可以传递字符串值(没有空格和其他元字符),而不引用:

代码语言:javascript
复制
Write-Output v2.2.3  # OK - quoting optional

有关这两种基本解析模式的更多信息,请参见概念性解析帮助主题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70822276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档