Open pinpox opened 3 years ago
Quick update: I think the command in that line is wrong:
if [ -n "$detachServer" ]; then
$server --root \"$path\" --host "$serverHost" --port "$port" >/dev/null & # This works!
serverPid=$!
echo "server listening on http://$serverHost:$port with pid ${serverPid}"
else
echo "server listening on http://$serverHost:$port"
echo "press Ctrl+C to stop"
$($server --root "$path" --host "$serverHost" --port "$port") # This is the line with the error
fi
fi
styx preview --detach
does not give the same error! The only differency I can see, is that the command for the detached option is not enclosed in $(...)
but the default preview command is. That seems to be the problem, it's trying to execute the whole line as one command. With --detach
I don't get the error, but the server seems not to be running, I get a 404
error when trying to browse localhost:8080
Yes styx preview [--detach]
both fail to start the server for me too.
The echo statements are printed, but then the service isn’t found running.
And as mentioned by @pinpox line 549 errors.
The problem seems to be a misuse of caddy: '[ERROR]' first argument must be a 'subcommand;' see ''\''caddy' 'help'\’’’
.
% styx --DEBUG preview-theme showcase
+ '[' 2 -gt 0 ']'
+ i=preview-theme
+ shift 1
+ case "$i" in
+ action=preview-theme
+ theme=showcase
+ shift 1
+ '[' 0 -gt 0 ']'
+ '[' '!' preview-theme ']'
+ '[' -z '' ']'
+ in=/Users/ldeck/Documents/dev/nix/styx
+ '[' preview-theme = new ']'
+ '[' preview-theme = new ']'
+ '[' preview-theme = gen-sample-data ']'
+ '[' preview-theme = preview-theme ']'
++ nix-build --no-out-link -A themes /nix/store/4y4ksqg4nz8kx6xiwlgma1qvd8dx1cl4-styx-0.7.2/share/styx-src
+ themesdir=/nix/store/1gvl25ysbn85bprncj77prsbj12xpy5d-styx-0.7.2-themes
++ nix-build --no-out-link -A showcase /nix/store/1gvl25ysbn85bprncj77prsbj12xpy5d-styx-0.7.2-themes
+ in=/nix/store/3il5n0dd2kq7ibr6585qdfv6v1h237sn-showcase-dev/example
+ '[' 0 -ne 0 ']'
+ '[' -z showcase ']'
+ action=serve
+ siteUrl=PREVIEW
+ '[' serve = theme-path ']'
+ '[' serve = site-doc ']'
+ '[' serve = build ']'
+ '[' serve = store-path ']'
+ '[' serve = serve ']'
+ '[' -z ']'
+ check_styx /nix/store/3il5n0dd2kq7ibr6585qdfv6v1h237sn-showcase-dev/example site.nix
+ '[' '!' -f /nix/store/3il5n0dd2kq7ibr6585qdfv6v1h237sn-showcase-dev/example/site.nix ']'
+ '[' PREVIEW = PREVIEW ']'
+ extraConf+=("siteUrl = \"http://$serverHost:$port\";")
+ extraFlags+=("--arg" "siteFile" $(realpath "$in/$siteFile"))
++ realpath /nix/store/3il5n0dd2kq7ibr6585qdfv6v1h237sn-showcase-dev/example/site.nix
++ SOURCE=/nix/store/3il5n0dd2kq7ibr6585qdfv6v1h237sn-showcase-dev/example/site.nix
++ '[' -h /nix/store/3il5n0dd2kq7ibr6585qdfv6v1h237sn-showcase-dev/example/site.nix ']'
++ echo /nix/store/3il5n0dd2kq7ibr6585qdfv6v1h237sn-showcase-dev/example/site.nix
++ store_build
++ extraConf+=("renderDrafts = $renderDrafts;")
++ extraFlags+=("--arg" "extraConf" "{ $(IFS=; echo "${extraConf[@]}") }")
+++ IFS=
+++ echo 'siteUrl = "http://127.0.0.1:8080";' 'renderDrafts = false;'
++ shift 2
++ nix-build -A site /nix/store/4y4ksqg4nz8kx6xiwlgma1qvd8dx1cl4-styx-0.7.2/share/styx-src/src/nix/site-builder.nix --no-out-link --arg siteFile /nix/store/3il5n0dd2kq7ibr6585qdfv6v1h237sn-showcase-dev/example/site.nix --arg extraConf '{ siteUrl = "http://127.0.0.1:8080"; renderDrafts = false; }'
+ path=/nix/store/hyc3dl501frdycmp6i6h81qk1ywn2m6k-styx-site
+ '[' 0 -ne 0 ']'
+ '[' -n '' ']'
+ echo 'server listening on http://127.0.0.1:8080'
server listening on http://127.0.0.1:8080
+ echo 'press Ctrl+C to stop'
press Ctrl+C to stop
++ /nix/store/wns0nix5zyq1k54lw05va912br9f0k4q-caddy-2.2.1/bin/caddy --root /nix/store/hyc3dl501frdycmp6i6h81qk1ywn2m6k-styx-site --host 127.0.0.1 --port 8080
+ '[ERROR]' first argument must be a 'subcommand;' see ''\''caddy' 'help'\'''
/Users/ldeck/.nix-profile/bin/styx: line 549: [ERROR]: command not found
+ '[' serve = linkcheck ']'
+ '[' serve = live ']'
+ '[' serve = deploy ']'
% nix-shell -p caddy styx
these paths will be fetched (1.46 MiB download, 7.85 MiB unpacked):
/nix/store/50wqnw14v6qlq455g5v0p104ajr3sz68-bash-interactive-4.4-p23-doc
/nix/store/85dv3mrr3fdina8bvwh6as4i3ijwcmn5-readline-7.0p5
/nix/store/bkmzimrsj5v4hhdnvk1kl0bqsj3i2b2l-bash-interactive-4.4-p23-man
/nix/store/dqaysswvv59q6whakf5z1digq2sn7m4w-bash-interactive-4.4-p23-dev
/nix/store/lixi1wps0g63r8ycjv4vpkahj69l0n80-bash-interactive-4.4-p23-info
/nix/store/zfp4da3hgwrag2zvyvrz383qaarqplwx-bash-interactive-4.4-p23
copying path '/nix/store/50wqnw14v6qlq455g5v0p104ajr3sz68-bash-interactive-4.4-p23-doc' from 'https://cache.nixos.org'...
copying path '/nix/store/lixi1wps0g63r8ycjv4vpkahj69l0n80-bash-interactive-4.4-p23-info' from 'https://cache.nixos.org'...
copying path '/nix/store/bkmzimrsj5v4hhdnvk1kl0bqsj3i2b2l-bash-interactive-4.4-p23-man' from 'https://cache.nixos.org'...
copying path '/nix/store/85dv3mrr3fdina8bvwh6as4i3ijwcmn5-readline-7.0p5' from 'https://cache.nixos.org'...
copying path '/nix/store/zfp4da3hgwrag2zvyvrz383qaarqplwx-bash-interactive-4.4-p23' from 'https://cache.nixos.org'...
copying path '/nix/store/dqaysswvv59q6whakf5z1digq2sn7m4w-bash-interactive-4.4-p23-dev' from 'https://cache.nixos.org'...
[nix-shell:~/Documents/dev/nix/styx]$ caddy help
Caddy is an extensible server platform.
usage:
caddy <command> [<args...>]
commands:
adapt Adapts a configuration to Caddy's native JSON
build-info Prints information about this build
environ Prints the environment
file-server Spins up a production-ready file server
fmt Formats a Caddyfile
hash-password Hashes a password and writes base64
help Shows help for a Caddy subcommand
list-modules Lists the installed Caddy modules
reload Changes the config of the running Caddy instance
reverse-proxy A quick and production-ready reverse proxy
run Starts the Caddy process and blocks indefinitely
start Starts the Caddy process in the background and then returns
stop Gracefully stops a started Caddy process
trust Installs a CA certificate into local trust stores
untrust Untrusts a locally-trusted CA certificate
validate Tests whether a configuration file is valid
version Prints the version
Use 'caddy help <command>' for more information about a command.
Full documentation is available at:
https://caddyserver.com/docs/command-line
Lines 543 and 549 both call caddy
without a <command>
.
% cat -n $(which styx) | sed -n '194,195p; 520,524p; 542,550p'
194 # server program
195 server=/nix/store/wns0nix5zyq1k54lw05va912br9f0k4q-caddy-2.2.1/bin/caddy
520 #-------------------------------
521 #
522 # Serve
523 #
524 #-------------------------------
542 if [ -n "$detachServer" ]; then
543 $server --root \"$path\" --host "$serverHost" --port "$port" >/dev/null &
544 serverPid=$!
545 echo "server listening on http://$serverHost:$port with pid ${serverPid}"
546 else
547 echo "server listening on http://$serverHost:$port"
548 echo "press Ctrl+C to stop"
549 $($server --root "$path" --host "$serverHost" --port "$port")
550 fi
I wonder if this was previously assuming caddy v1 in the past? Caddy v2 seems to have a completely different api.
I can try to fix this by using an older version of caddy.
Just noting that with the command styx preview-theme showcase
this issue is still present.
$ nix-shell -p styx
$ styx preview-theme showcase
server listening on http://127.0.0.1:8080
press Ctrl+C to stop
/nix/store/gl741k47nrsqaj7d6k3mn4j30nrqq3yp-styx-0.7.2/bin/styx: line 549: [ERROR]: command not found
(I presume that everything else works because I couldn't find other issues, and I literally just found out about this project; I'm going through the documentation and this was the first styx
command I came across.)
caddy1 removed from nixpkgs here
https://github.com/NixOS/nixpkgs/commit/8f74e9e90541fdc34a4eb228d7dbab5ff761c20d
as styx depends on caddy1, the script is going to need to be upgraded to use caddy2. Maybe the styx should not rely on a web server at all, and just generate a webroot, allowing the user to run what ever webserver they want, but it does make deployment a little easier.
if you want to temporarly get styx working with caddy 1 , try this
git clone https://github.com/NixOS/nixpkgs.git
cd nixpkgs
git checkout 069ca7e897cc9428dc78c0ee941499ab8c00b70b
cd ..
nix-shell -I . -p styx
styx preview-theme showcase
this will at least get you working with an older version of caddy (caddy 1 which isn't supported).
Upgrading styx to use caddy2 , or removing the dependency on any particular web server are also options.
I'm not familiar with caddy, so perhaps reverting the change to caddy2 would be a temporary fix.
Hello,
I installed styx with home-manager. It is working mostly:
styx new site
andstyx build
work as expected, but anything related to previews seems to be broken:Line 549 is this:
Is there some dependency missing? What is $server supposed to be?