Skip to content

Daemon fails when dvc is called via a wrapper script. #4206

@danfischetti

Description

@danfischetti

Bug Report

Currently, our build system is managed with nix , which stores python packages in a non-standard directory structure. To manage this, as part of the installation process, nix will wrap any executables provided by a package in a wrapper script which sets up the proper environment for that script.

The issue is that the daemon (which is trying to start the updater process on every command) tries to execute sys.argv[0] as a python script, even though it's a shell script, leading to a syntax error.

Here are the lines in question.

dvc/dvc/daemon.py

Lines 90 to 93 in c1b04b8

cmd = [sys.executable]
if not is_binary():
cmd += [sys.argv[0]]
cmd += ["daemon", "-q"] + args

Here's what our wrapper script looks like

#! /nix/store/z1l2n01xdfcm9bkkir83c32mkpvv51zq-bash-4.4-p23/bin/bash -e
export PATH='/nix/store/vhivkaa093jrfb0lfkhf2dl6qkzzhb70-python3-3.6.10/bin:/nix/store/gsb1a6b9nyzmfwxnsalgf5w62bmi83hr-python3.6-dvc-1.1.1/bin:/nix/store/7vvn623206kr6kj8sp6260qmq4kgmvz8-python3.6-distro-1.5.0/bin:/nix/store/p2vylslfgi6p7rd87ai3h6xrhgqd6idz-python3.6-flatten-json-0.1.7/bin:/nix/store/fmnzmxwin3d0981r5yj1jq7kiyljdahp-git-2.26.1/bin:/nix/store/xpcpx849dy54x1r3m8hsv0r7vsxf7iv4-python3.6-future-0.18.2/bin:/nix/store/fladadzc5zcdgpj812mqjyh54lx1n18v-python3.6-jsonpath-ng-1.5.1/bin:/nix/store/05g6dph7rwnw8f3g57pjg5r4rrs2ybvj-python3.6-chardet-3.0.4/bin:/nix/store/4snfznrv0f8zvz7qh9si9nbbh8lx6228-python3.6-setuptools-45.2.0/bin:/nix/store/dz78l5d7zpvbdxvps774ni2f18qz7b00-python3.6-shtab-1.1.0/bin:/nix/store/ak2qwj9l94hvbyqpavlmcsf832ci3q2n-python3.6-tabulate-0.8.7/bin:/nix/store/xs4xkyc66s7zpd7dr5lb8h2h34krnyhn-python3.6-tqdm-4.45.0/bin'${PATH:+':'}$PATH
export PYTHONNOUSERSITE='true'
exec -a "$0" "/nix/store/gsb1a6b9nyzmfwxnsalgf5w62bmi83hr-python3.6-dvc-1.1.1/bin/.dvc-wrapped"  "$@"

and the resulting syntax error that shows up for every command

$ dvc status
  File "/nix/store/gsb1a6b9nyzmfwxnsalgf5w62bmi83hr-python3.6-dvc-1.1.1/bin/dvc", line 2
    export PATH='/nix/store/vhivkaa093jrfb0lfkhf2dl6qkzzhb70-python3-3.6.10/bin:/nix/store/gsb1a6b9nyzmfwxnsalgf5w62bmi83hr-python3.6-dvc-1.1.1/bin:/nix/store/7vvn623206kr6kj8sp6260qmq4kgmvz8-python3.6-di
stro-1.5.0/bin:/nix/store/p2vylslfgi6p7rd87ai3h6xrhgqd6idz-python3.6-flatten-json-0.1.7/bin:/nix/store/fmnzmxwin3d0981r5yj1jq7kiyljdahp-git-2.26.1/bin:/nix/store/xpcpx849dy54x1r3m8hsv0r7vsxf7iv4-python3.6
-future-0.18.2/bin:/nix/store/fladadzc5zcdgpj812mqjyh54lx1n18v-python3.6-jsonpath-ng-1.5.1/bin:/nix/store/05g6dph7rwnw8f3g57pjg5r4rrs2ybvj-python3.6-chardet-3.0.4/bin:/nix/store/4snfznrv0f8zvz7qh9si9nbbh8
lx6228-python3.6-setuptools-45.2.0/bin:/nix/store/dz78l5d7zpvbdxvps774ni2f18qz7b00-python3.6-shtab-1.1.0/bin:/nix/store/ak2qwj9l94hvbyqpavlmcsf832ci3q2n-python3.6-tabulate-0.8.7/bin:/nix/store/xs4xkyc66s7
zpd7dr5lb8h2h34krnyhn-python3.6-tqdm-4.45.0/bin'${PATH:+':'}$PATH
              ^
SyntaxError: invalid syntax

^CERROR: interrupted by the user

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!

Please provide information about your setup

Output of dvc version:

$ dvc version
DVC version: 1.1.1
Python version: 3.6.10
Platform: Linux-4.4.0-141-generic-x86_64-with-debian-stretch-sid
Binary: False
Package: pip
Supported remotes: gs, hdfs, http, https
Cache: reflink - not supported, hardlink - supported, symlink - supported
Filesystem type (cache directory): ('lustre', '172.16.1.1@o2ib:/es0')
Repo: dvc, git
Filesystem type (workspace): ('lustre', '172.16.1.1@o2ib:/es0')

Additional Information (if any):

If applicable, please also provide a --verbose output of the command, eg: dvc add --verbose.

Metadata

Metadata

Assignees

Labels

bugDid we break something?p1-importantImportant, aka current backlog of things to do

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions