diff --git a/bot.py b/bot.py index b635c9b..d54d062 100644 --- a/bot.py +++ b/bot.py @@ -197,6 +197,10 @@ def main() -> None: action="store_true", help="Execute real orders (default is paper trading)", ) + # Always work relative to the script's own directory so that bot.log and + # positions.json land in /opt/crypto-trader regardless of the caller's cwd. + os.chdir(os.path.dirname(os.path.abspath(__file__))) + args = parser.parse_args() config = Config() diff --git a/install.sh b/install.sh index 4ffcf9b..ecfdbbc 100644 --- a/install.sh +++ b/install.sh @@ -54,7 +54,9 @@ fi echo "Ensuring python3-venv and pip are available..." apt-get install -y python3-venv python3-pip -if [ ! -d "$INSTALL_DIR/venv" ]; then +# Check for pip specifically — a previous failed run may have left an incomplete venv +if [ ! -f "$INSTALL_DIR/venv/bin/pip" ]; then + rm -rf "$INSTALL_DIR/venv" python3 -m venv "$INSTALL_DIR/venv" || { echo "ERROR: 'python3 -m venv' failed. Try: apt-get install python3-venv" exit 1