forked from phoenix-oss/llama-stack-mirror
# What does this PR do?
I was encountering build issues when building my `ollama` environment
using `llama stack build`
```bash
llama stack build --template ollama --image-type venv
Traceback (most recent call last):
File "/Users/farceo/dev/llama-stack/.venv/bin/llama", line 10, in <module>
sys.exit(main())
^^^^^^
File "/Users/farceo/dev/llama-stack/llama_stack/cli/llama.py", line 46, in main
parser.run(args)
File "/Users/farceo/dev/llama-stack/llama_stack/cli/llama.py", line 40, in run
args.func(args)
File "/Users/farceo/dev/llama-stack/llama_stack/cli/stack/build.py", line 77, in _run_stack_build_command
return run_stack_build_command(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/farceo/dev/llama-stack/llama_stack/cli/stack/_build.py", line 180, in run_stack_build_command
_run_stack_build_command_from_build_config(
File "/Users/farceo/dev/llama-stack/llama_stack/cli/stack/_build.py", line 272, in _run_stack_build_command_from_build_config
return_code = build_image(
^^^^^^^^^^^^
File "/Users/farceo/dev/llama-stack/llama_stack/distribution/build.py", line 137, in build_image
return_code = run_with_pty(args)
^^^^^^^^^^^^^^^^^^
File "/Users/farceo/dev/llama-stack/llama_stack/distribution/utils/exec.py", line 22, in run_with_pty
return _run_with_pty_unix(command)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/farceo/dev/llama-stack/llama_stack/distribution/utils/exec.py", line 53, in _run_with_pty_unix
process = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/Users/farceo/.local/share/uv/python/cpython-3.11.6-macos-aarch64-none/lib/python3.11/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/farceo/.local/share/uv/python/cpython-3.11.6-macos-aarch64-none/lib/python3.11/subprocess.py", line 1950, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/farceo/dev/llama-stack/llama_stack/distribution/build_venv.sh'
make: *** [build-ollama] Error 1
```
I also had to adjust the script when testing the `common.sh` file
because it returned:
```bash
> source llama_stack/distribution/common.sh
llama_stack/distribution/common.sh:6: command not found: ^M
llama_stack/distribution/common.sh:50: parse error near `\n'
```
On my branch, I ran:
```bash
sed -i '' 's/\r$//' llama_stack/distribution/common.sh
```
And then I was able to successfully build the environment.
[//]: # (If resolving an issue, uncomment and update the line below)
[//]: # (Closes #[issue-number])
## Test Plan
N/A
[//]: # (## Documentation)
N/A
---------
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
49 lines
931 B
Bash
Executable file
49 lines
931 B
Bash
Executable file
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
cleanup() {
|
|
envname="$1"
|
|
|
|
set +x
|
|
echo "Cleaning up..."
|
|
conda deactivate
|
|
conda env remove --name "$envname" -y
|
|
}
|
|
|
|
handle_int() {
|
|
if [ -n "$ENVNAME" ]; then
|
|
cleanup "$ENVNAME"
|
|
fi
|
|
exit 1
|
|
}
|
|
|
|
handle_exit() {
|
|
if [ $? -ne 0 ]; then
|
|
echo -e "\033[1;31mABORTING.\033[0m"
|
|
if [ -n "$ENVNAME" ]; then
|
|
cleanup "$ENVNAME"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
setup_cleanup_handlers() {
|
|
trap handle_int INT
|
|
trap handle_exit EXIT
|
|
|
|
if is_command_available conda; then
|
|
__conda_setup="$('conda' 'shell.bash' 'hook' 2>/dev/null)"
|
|
eval "$__conda_setup"
|
|
conda deactivate
|
|
else
|
|
echo "conda is not available"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# check if a command is present
|
|
is_command_available() {
|
|
command -v "$1" &>/dev/null
|
|
}
|