NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.38k stars 14.33k forks source link

Can't run setup.py; getting "Permission denied" error #7088

Closed adnelson closed 9 years ago

adnelson commented 9 years ago

I'm writing a nix expression for the uwsgi package. I've run git clone https://github.com/unbit/uwsgi, and added the following default.nix to the uwsgi directory:

with import <nixpkgs> {};

buildPythonPackage {
  name = "uwsgi";
  version = "2.1";
  src = ./.;
}

Interestingly, I can run nix-env -i -f . and everything will install correctly. However, I wanted to run the tests of the package; to do this I wanted to run nix-shell --pure, then run the test suite. However, when I run nix-shell --pure, it fails:

these paths will be fetched (3.57 MiB download, 14.74 MiB unpacked):
  /nix/store/103cmsmivfs5bfggf63c7mca55c62hxw-patch-2.7.3
  /nix/store/2sl16wg044d0iinnzpmbsyf2grwis76n-paxctl-0.9
  /nix/store/4md5y07qr9yfy6phc5wx2yv72m9zxfx7-xz-5.2.0
  /nix/store/6cxz5k48girakwz41y86qc70981q0chx-ed-1.10
  /nix/store/6d9znydry7awh1xd3q0ks752w900m7lg-findutils-4.4.2
  /nix/store/bf1arcwsggzygypnxm5r2sni97cdnsvi-python2.7-distutils.cfg
  /nix/store/d1fhd9bjjxsfglw8052yc9j19p95xlhk-hook
  /nix/store/dacpq6as15v4wxvby0051hfw8y455cha-gnumake-3.82
  /nix/store/h5qhpwjf2mb69y2s9xlx3cpf9fh5xpc9-gzip-1.6
  /nix/store/higz8rfx70lh0ch9spakzpi7rmiqqv8b-distutils.cfg
  /nix/store/ji17paqnmki2x028h0gkrklckksf5036-patchelf-0.8
  /nix/store/jrwzg2azb5j76ycha47k2q765m91vwyq-gnutar-1.27.1
  /nix/store/kkh13biykhc9vlqs8w9w6rhj13yaw3md-diffutils-3.3
  /nix/store/s81slvsk9aw6x9qp732wgj7pkarbvknk-gnugrep-2.20
  /nix/store/v2k7xsqs6jpvd3vx5rh2b206m74598s1-stdenv
  /nix/store/vsqhfi2dnm38k733y4wpbpvwyb1yw6wg-libsigsegv-2.10
  /nix/store/wb5aj7k6237p0izlflfj3kvd69a18rcy-gnused-4.2.2
  /nix/store/x9158814jwzb0lvqh3lwfpdvhg5mv8fv-gawk-4.1.0
  /nix/store/xq9v6jwrf6w0ymz7xilzhkd2nwl3hi7j-pcre-8.36
  /nix/store/ykimjbx9nvac6h0dxrcsjw8vh31l023g-hook
fetching path ‘/nix/store/higz8rfx70lh0ch9spakzpi7rmiqqv8b-distutils.cfg’...

[...snip...]

*** uWSGI linking ***
gcc -o /nix/store/mi3k70qyq1qd3cp913vnbwz7f5wbkg9a-python-2.7.9/bin/uwsgi -L/nix/store/mi3k70qyq1qd3cp913vnbwz7f5wbkg9a-python-2.7.9/lib core/utils.o core/protocol.o core/socket.o core/logging.o core/master.o core/master_utils.o core/emperor.o core/notify.o core/mule.o core/subscription.o core/stats.o core/sendfile.o core/async.o core/master_checks.o core/fifo.o core/offload.o core/io.o core/static.o core/websockets.o core/spooler.o core/snmp.o core/exceptions.o core/config.o core/setup_utils.o core/clock.o core/init.o core/buffer.o core/reader.o core/writer.o core/alarm.o core/cron.o core/hooks.o core/plugins.o core/lock.o core/cache.o core/daemons.o core/errors.o core/hash.o core/master_events.o core/chunked.o core/queue.o core/event.o core/signal.o core/strings.o core/progress.o core/timebomb.o core/ini.o core/fsmon.o core/mount.o core/metrics.o core/plugins_builder.o core/sharedarea.o core/fork_server.o core/webdav.o core/zeus.o core/rpc.o core/gateway.o core/loop.o core/cookie.o core/querystring.o core/rb_timers.o core/transformations.o core/uwsgi.o proto/base.o proto/uwsgi.o proto/http.o proto/fastcgi.o proto/scgi.o proto/puwsgi.o lib/linux_ns.o core/yaml.o core/dot_h.o core/config_py.o plugins/python/python_plugin.o plugins/python/pyutils.o plugins/python/pyloader.o plugins/python/wsgi_handlers.o plugins/python/wsgi_headers.o plugins/python/wsgi_subhandler.o plugins/python/web3_subhandler.o plugins/python/pump_subhandler.o plugins/python/gil.o plugins/python/uwsgi_pymodule.o plugins/python/profiler.o plugins/python/symimporter.o plugins/python/tracebacker.o plugins/python/raw.o plugins/gevent/gevent.o plugins/gevent/hooks.o plugins/ping/ping_plugin.o plugins/cache/cache.o plugins/nagios/nagios.o plugins/rrdtool/rrdtool.o plugins/carbon/carbon.o plugins/rpc/rpc_plugin.o plugins/corerouter/cr_common.o plugins/corerouter/cr_map.o plugins/corerouter/corerouter.o plugins/fastrouter/fastrouter.o plugins/http/http.o plugins/http/keepalive.o plugins/http/https.o plugins/http/spdy3.o plugins/ugreen/ugreen.o plugins/signal/signal_plugin.o plugins/syslog/syslog_plugin.o plugins/rsyslog/rsyslog_plugin.o plugins/logsocket/logsocket_plugin.o plugins/router_uwsgi/router_uwsgi.o plugins/router_redirect/router_redirect.o plugins/router_basicauth/router_basicauth.o plugins/zergpool/zergpool.o plugins/redislog/redislog_plugin.o plugins/mongodblog/mongodblog_plugin.o plugins/router_rewrite/router_rewrite.o plugins/router_http/router_http.o plugins/logfile/logfile.o plugins/router_cache/router_cache.o plugins/rawrouter/rawrouter.o plugins/router_static/router_static.o plugins/sslrouter/sslrouter.o plugins/spooler/spooler_plugin.o plugins/cheaper_busyness/cheaper_busyness.o plugins/symcall/symcall_plugin.o plugins/transformation_tofile/tofile.o plugins/transformation_gzip/gzip.o plugins/transformation_chunked/chunked.o plugins/transformation_offload/offload.o plugins/router_memcached/router_memcached.o plugins/router_redis/router_redis.o plugins/router_hash/router_hash.o plugins/router_expires/expires.o plugins/router_metrics/plugin.o plugins/transformation_template/tt.o plugins/stats_pusher_socket/plugin.o -lpthread -lm -rdynamic -ldl -lpthread -ldl -lutil -lm -lpython2.7 -lcrypt
/nix/store/lcv1lkgmxdhpiw7b9k25xr9yfpxpilzc-binutils-2.23.1/bin/ld: cannot open output file /nix/store/mi3k70qyq1qd3cp913vnbwz7f5wbkg9a-python-2.7.9/bin/uwsgi: Permission denied
collect2: error: ld returned 1 exit status
*** error linking uWSGI ***

Looking into this myself, it looks like the folder is read-only, which is why the binary cannot be created:

$ ls -lah /nix/store/mi3k70qyq1qd3cp913vnbwz7f5wbkg9a-python-2.7.9/bin
total 60K
dr-xr-xr-x 2 anelson anelson 4.0K Dec 31  1969 .
dr-xr-xr-x 7 anelson anelson 4.0K Dec 31  1969 ..
-r-xr-xr-x 1 anelson anelson  147 Dec 31  1969 2to3
-r-xr-xr-x 1 anelson anelson  145 Dec 31  1969 idle
lrwxrwxrwx 1 anelson anelson   77 Dec 31  1969 pdb -> /nix/store/mi3k70qyq1qd3cp913vnbwz7f5wbkg9a-python-2.7.9/lib/python2.7/pdb.py
lrwxrwxrwx 1 anelson anelson   77 Dec 31  1969 pdb2.7 -> /nix/store/mi3k70qyq1qd3cp913vnbwz7f5wbkg9a-python-2.7.9/lib/python2.7/pdb.py
-r-xr-xr-x 1 anelson anelson  130 Dec 31  1969 pydoc
lrwxrwxrwx 1 anelson anelson    7 Dec 31  1969 python -> python2
lrwxrwxrwx 1 anelson anelson    9 Dec 31  1969 python2 -> python2.7
-r-xr-xr-x 1 anelson anelson 7.5K Dec 31  1969 python2.7
-r-xr-xr-x 1 anelson anelson 1.7K Dec 31  1969 python2.7-config
lrwxrwxrwx 1 anelson anelson   16 Dec 31  1969 python2-config -> python2.7-config
lrwxrwxrwx 1 anelson anelson   14 Dec 31  1969 python-config -> python2-config
-r-xr-xr-x 1 anelson anelson  19K Dec 31  1969 smtpd.py

What can I do to get around this? Also, and I know this has come up before, but why is the setup.py for uwsgi being run in the first place? My understanding of nix-shell was that it builds all of the packages dependencies and sets up environment variables -- but does not build the actual package itself.

joachifm commented 9 years ago

I don't know how to fix your specific problem, but I believe that if you omit the src attribute, you'll get what you want (i.e., a shell environment suitable for working with the package). Add more stuff to the environment via buildInputs. Also, supplying a version is redundant in this case. That's how I use nix-shell, anyway.

adnelson commented 9 years ago

Why is specifying a version redundant?

joachifm commented 9 years ago

It's redundant in the sense that it's not required for getting a working shell environment. I don't know what buildPythonPackage does with version, but it's normally just used as a suffix for name.

domenkozar commented 9 years ago

@adnelson we already have uwsgi package which apparently doesn't use typical setup.py installations: https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/uwsgi/default.nix