Linux

p4:沒有這樣的文件或目錄-實際上它存在

  • February 6, 2018

我在伺服器上安裝了 p4 命令行客戶端,但發生了一些奇怪的事情。它存在,具有可執行權限,但我無法執行它,因為我收到一條錯誤消息,指出它不存在。

我試著環顧四周,其他遇到這個問題的人都意識到他們為他們的盒子選擇了錯誤的二進製文件,但我 100% 確定我沒有。

/usr/local/bin/p4 文件是:

  • 0x0755
  • 在我的 $PATH 目錄(/usr/local/bin)中
  • 存在於正確的位置
  • 嘗試以 root 和 ubuntu 使用者身份執行

這是我的終端輸出:

ubuntu@ubuntu:~$ sudo su
+ sudo su

root@ubuntu:/home/ubuntu# wget http://cdist2.perforce.com/perforce/r16.1/bin.freebsd100x86_64/p4
--2017-09-25 22:21:45--  http://cdist2.perforce.com/perforce/r16.1/bin.freebsd100x86_64/p4
Resolving cdist2.perforce.com (cdist2.perforce.com)... 54.192.36.127, 54.192.36.104, 54.192.36.217, ...
Connecting to cdist2.perforce.com (cdist2.perforce.com)|54.192.36.127|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3683848 (3.5M) [application/x-executable]
Saving to: ‘p4’

100%[===================================================================================================================>] 3,683,848   5.06MB/s   in 0.7s

2017-09-25 22:21:46 (5.06 MB/s) - ‘p4’ saved [3683848/3683848]

root@ubuntu:/home/ubuntu# chmod +x p4

root@ubuntu:/home/ubuntu# mv p4 /usr/local/bin/

root@ubuntu:/home/ubuntu# p4
bash: /usr/local/bin/p4: No such file or directory

root@ubuntu:/home/ubuntu# ls -lah /usr/local/bin/p4
-rwxr-xr-x 1 root root 3.6M Mar  2  2017 /usr/local/bin/p4

root@ubuntu:/home/ubuntu# file /usr/local/bin/p4
/usr/local/bin/p4: ELF 64-bit LSB  executable, x86-64, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 10.0 (1000510), stripped

root@ubuntu:/home/ubuntu# uname -m
x86_64

任何幫助是極大的讚賞!

好的,我找到了一個解決方案,我將我的配置腳本更改為這個,它工作正常。我不知道為什麼這解決了我的問題……

#!/bin/bash

# bash strict and verbose mode
set -o pipefail -e -u -x

if [ ! -z `which p4` ]; then
 exit 0
fi

# Installs Perforce

echo "deb http://package.perforce.com/apt/ubuntu/ trusty release" > /etc/apt/sources.list.d/perforce.list
wget -qO - https://package.perforce.com/perforce.pubkey | apt-key add -
apt-get update
apt-get install -y helix-cli

令人困惑的“沒有這樣的文件或目錄”實際上可能指的是這個(不合適的!)二進製文件試圖呼叫的任何動態連結器。

引用自:https://serverfault.com/questions/875448