Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sed:无法读取 s|github.com/qit-team/snow|my-github/my-space/my-project|:没有那个文件或目录 #5

Closed
taozywu opened this issue Jul 12, 2019 · 6 comments

Comments

@taozywu
Copy link

taozywu commented Jul 12, 2019

@hetiansu5

cd $GOPATH/src
# 进入新项目的仓库地址+空间目录
cd my-github/my-space
# 下载源码包,保存为新项目名
git clone git@github.com:qit-team/snow.git my-project
# 进入项目根目录
cd my-project
# 替换为新项目的包命名空间
sh build/shell/replace.sh my-github/my-space/my-project
# 复制样例环境配置为当前环境配置
cp .env.example .env

当走到 sh build/shell/replace.sh my-github/my-space/my-project 这一步的时候, 会报如下错误!!

sed:无法读取 s|github.com/qit-team/snow|my-github/my-space/my-project|:没有那个文件或目录

从如上理解:sed是替换的意思,大致是将github.com/qit-team/snow替换成my-github/my-space/my-project

先抛开问题,咱们看一下build/shell/replace.sh这个文件。

#/bin/bash
# 将项目的包命名空间统一替换成目标目录空间
target=$1
default="github.com/qit-team/snow"
if [ "$target" == "" ]; then
    target="$default"
fi

#回到根目录
rootPath=$(cd `dirname $0`/../../; pwd)

#替换
find . -type f -name "*.*" ! -path "./vendor/*" ! -path "./logs/*" ! -path "./docs/*"  ! -path "./.git/*" ! -path "./build/shell/replace.sh" | xargs sed -i "" "s|${default}|${target}|"

从上面的文件我们能得出几点

  1. rootPath应该是没用吧?
  2. 先查满足规则的文件名(排除几个目录)
  3. 替换sed命令,我是centos,用s|old|new| 应该是不对吧?你的是mac?

====

总之在当走到 sh build/shell/replace.sh my-github/my-space/my-project 这一步的时候, 会报如下错误!!还请抽空帮看下,感谢!!

@taozywu
Copy link
Author

taozywu commented Jul 12, 2019

@hetiansu5

替换那块我尝试改成如下是ok的

find . -type f -name "*.*" ! -path "./vendor/*" ! -path "./logs/*" ! -path "./docs/*"  ! -path "./.git/*" ! -path "./build/shell/replace.sh" | xargs sed -i "s/github.com\/qit-team\/snow/my-github\/my-space\/my-project/g"

@hetiansu5
Copy link
Collaborator

谢谢,我晚点下班的时候review一下。欢迎提的PR,嘿嘿~

@hetiansu5
Copy link
Collaborator

@taozywu sed替换mac和linux的有点不太一样,使用mac开发忘了兼容linux了。

@hetiansu5
Copy link
Collaborator

已经修复了

@taozywu
Copy link
Author

taozywu commented Jul 12, 2019

@hetiansu5 thx

@almas1992
Copy link

almas1992 commented Jul 12, 2019

该项目是不是没法在Windows系统中跑起来,Build时报undefined: syscall.SIGUSR1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants