Daniel15 / simple-nuget-server

A very simple PHP NuGet server
MIT License
116 stars 43 forks source link

"Root element is missing" Error; SQLite3 file not being created? #31

Open dougthor42 opened 6 years ago

dougthor42 commented 6 years ago

So I've successfully pushed a test package, but now I am getting an error "Root element is missing" when trying to list the packages:

PS C:\gitlab\dthor\NuGetTest\NuGetTest\bin\Release> nuget push .\NuGetTest.0.0.1.nupkg -Source http://nuget.redacted.local
Pushing NuGetTest.0.0.1.nupkg to 'http://nuget.redacted.local'...
  PUT http://nuget.redacted.local/api/v2/package/
  OK http://nuget.redacted.local/api/v2/package/ 36ms
Your package was pushed.
PS C:\gitlab\dthor\NuGetTest\NuGetTest\bin\Release> nuget list -source http://nuget.redacted.local
Root element is missing.

I looked through the source code a bit and saw that it's supposed to create an SQLite DB file at ./db/packages.sqlite3 by default, and store the package file itself in ./packagefiles/. However, neither of these files are created on push.

$ pwd
/var/www/simple-nuget-server
$ ll
total 48K
drwxr-xr-x 7 root     root     4.0K Mar  2 08:58 ./
drwxr-xr-x 4 root     root     4.0K Mar  2 08:58 ../
drwxrwx--- 2 www-data www-data 4.0K Mar  2 08:58 db/
drwxr-xr-x 8 root     root     4.0K Apr 17 08:52 .git/
drwxr-xr-x 2 root     root     4.0K Mar  2 08:58 inc/
drwxrwx--- 2 www-data www-data 4.0K Mar  2 08:58 packagefiles/
drwxr-xr-x 2 root     root     4.0K Mar  2 08:58 public/
-rw-r--r-- 1 root     root      132 Mar  2 08:58 .editorconfig
-rw-r--r-- 1 root     root       32 Mar  2 08:58 .gitignore
-rw-r--r-- 1 root     root     1.1K Mar  2 08:58 LICENSE
-rw-r--r-- 1 root     root     1.3K Mar  2 08:58 nginx.conf.example
-rw-r--r-- 1 root     root     3.9K Mar  2 08:58 README.md
$ sudo ll db/
total 8.0K
drwxrwx--- 2 www-data www-data 4.0K Mar  2 08:58 ./
drwxr-xr-x 7 root     root     4.0K Mar  2 08:58 ../
-rw-r--r-- 1 root     root        0 Mar  2 08:58 .gitkeep
$ sudo ll packagefiles/
total 8.0K
drwxrwx--- 2 www-data www-data 4.0K Mar  2 08:58 ./
drwxr-xr-x 7 root     root     4.0K Mar  2 08:58 ../
-rw-r--r-- 1 root     root        0 Mar  2 08:58 .gitkeep

Nginx shows no error in the logs, and /var/log/nginx/access.log looks like:

192.168.11.124 - - [17/Apr/2018:08:57:28 -0700] "PUT /api/v2/package/ HTTP/1.1" 200 56 "-" "NuGet Command Line/4.6.2 (Microsoft Windows NT 6.2.9200.0)"
192.168.11.124 - - [17/Apr/2018:08:57:33 -0700] "GET / HTTP/1.1" 200 31 "-" "NuGet Command Line/4.6.2 (Microsoft Windows NT 6.2.9200.0)"
192.168.11.124 - - [17/Apr/2018:08:57:33 -0700] "GET /$metadata HTTP/1.1" 200 4509 "-" "NuGet Command Line/4.6.2 (Microsoft Windows NT 6.2.9200.0)"
192.168.11.124 - - [17/Apr/2018:08:57:33 -0700] "GET /Search()?$filter=IsLatestVersion&$orderby=Id&searchTerm=''&targetFramework=''&includePrerelease=false&$skip=0&$top=30&semVerLevel=2.0.0 HTTP/1.1" 200 31 "-" "NuGet Command Line/4.6.2 (Microsoft Windows NT 6.2.9200.0)"

Versions:

(It's hard to see in the output, but ngx_http_dav_module is indeed installed)

$ php --version
PHP 7.0.28-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.28-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
$ nginx -V
nginx version: nginx/1.10.3 (Ubuntu)
built with OpenSSL 1.0.2g  1 Mar 2016
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_secure_link_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-threads --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/headers-more-nginx-module --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-auth-pam --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-cache-purge --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-dav-ext-module --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-development-kit --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-echo --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/ngx-fancyindex --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-http-push --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-lua --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-upload-progress --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-upstream-fair --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/ngx_http_substitutions_filter_module
Daniel15 commented 6 years ago

Hmmm, interesting. Anything in /var/log/nginx/error.log (or the site-specific error log, if you've configure one)?

dougthor42 commented 6 years ago

No errors in the logs.

I tried adding things like file_put_contents to start debugging, but for some reason none of that worked. I have zero experience with php and nginx, so it might just be PEBKAC.

In the interim, I'm porting things to python (https://github.com/dougthor42/pynuget) so that (1) I can understand the project and (2) I can debug things in the future.

gekkedev commented 6 years ago

Same problem here, the logfiles are empty when pushing packages via NuGet. I've managed to create packages.sqlite3 running the index.php in the public folder via PHP-CLI as root...it's empty though. Even after pushing a package (returns http code 200) all tables stay empty and no packages are being saved.

stemoser commented 5 years ago

The same happened to me. I solved checking the nginx configuration for the site. The default configuration forgets to "include snippets/fastcgi-php.conf;" (maybe something changed from previous nginx version?).

steakhal commented 5 years ago

I'm still facing the same issue @stemoser.