Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
/bin/sh: ./check-dependencies.pl: not found — but check-dependencies.pl exists!

I obtain an error when I compile moses-script, which reads as follows:

minakshi@minakshi-Vostro-3500:~/Desktop/monu/moses/scripts$ make release
# Compile the parts
make all
make[1]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts'
# Building memscore may fail e.g. if boost is not available.
# We ignore this because traditional scoring will still work and memscore isn't used by default.
cd training/memscore ; \
      ./configure && make \
      || ( echo "WARNING: Building memscore failed."; \
           echo 'training/memscore/memscore' >> ../../release-exclude )
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for boostlib >= 1.31.0... yes
checking for cos in -lm... yes
checking for gzopen in -lz... yes
checking for cblas_dgemm in -lgslcblas... no
checking for gsl_blas_dgemm in -lgsl... no
checking how to run the C++ preprocessor... g++ -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking n_gram.h usability... no
checking n_gram.h presence... no
checking for n_gram.h... no
checking for size_t... yes
checking for ptrdiff_t... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/memscore'
make  all-am
make[3]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/memscore'
make[3]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/memscore'
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/memscore'
touch release-exclude # No files excluded by default
pwd=`pwd`; \
    for subdir in cmert-0.5 phrase-extract symal mbr lexical-reordering; do \
      make -C training/$subdir || exit 1; \
      echo "### Compiler $subdir"; \
      cd $pwd; \
    done
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/cmert-0.5'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/cmert-0.5'
### Compiler cmert-0.5
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/phrase-extract'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/phrase-extract'
### Compiler phrase-extract
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/symal'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/symal'
### Compiler symal
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/mbr'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/mbr'
### Compiler mbr
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/lexical-reordering'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/lexical-reordering'
### Compiler lexical-reordering
## All files that need compilation were compiled
make[1]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts'
/bin/sh: ./check-dependencies.pl: not found
make: *** [release] Error 127

We don't know why this error occurs? check-dependencies.pl file existed in scripts folder ...

share|improve this question
add comment

migrated from askubuntu.com Oct 29 '12 at 22:41

This question came from our site for Ubuntu users and developers.

marked as duplicate by Michael Mrozek Oct 30 '12 at 4:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

My hunch: ./check-dependencies.pl begins with #!/usr/local/bin/perl. Change the first line to #!/usr/bin/perl.

Explanation: when you run a program, the kernel loads the file into memory and executes it. However, many executables (most of them, in fact) cannot be executed directly but require another program, a loader:

  • Most binary programs are dynamically linked, and must be loaded by the dynamic linker (/lib/ld-linux.so.2 for 32-bit programs, /lib64/ld-linux-x86-64.so.2 for 64-bit programs) which takes care of loading the libraries requested by the program.
  • Scripts must be loaded by their interpreter.

The kernel recognizes a script because it begins with a shebang line. A shebang line is the first line of the script and consists of the characters #! followed by the full path to the interpreter. Optionally the line may also contain a space followed by one argument that is passed to the interpreter.

For example, if a script begins with #!/usr/local/bin/perl -w, then when the kernel is told to execute that script, it executes /usr/local/bin/perl -w /path/to/script. If it cannot execute /usr/local/bin/perl, you get an error message. Because the kernel can only report an error code and no additional information, the information from the kernel is identical if the script doesn't exist or if the interpreter doesn't exist.

Some shells double-check the error condition in that case, and print a different message such as “bad interpreter” when the script exists but the kernel reports “file not found”. But the default scripting shell on Ubuntu (/bin/sh) is Dash, a shell that is design to execute scripts fast and doesn't have extra convenience features like this. So you get the plain “file not found” report.

A lot of Perl scripts around start with #!/usr/local/bin/perl, which is the path to Perl on most non-Linux installations. You may find it helpful to create that on your machine — make it a symbolic link to /usr/bin/perl, and do the same for other interpreters while you're at it.

cd /usr/local/bin
ln -s ../../../bin/bash ../../bin/perl ../../bin/python ../../bin/ruby .

When you're writing a script, you can avoid this issue by writing a shebang line like #!/usr/bin/env perl. This can only be done if you aren't passing arguments to the interpreter. See Why is it better to use “#!/usr/bin/env NAME” instead of “#!/path/to/NAME” as my shebang? for a discussion of that possibility.

share|improve this answer
add comment