how can I change the settings (e.g., port) used by "yesod devel"? - yesod

I know I can put port numbers in config/settings.yml but they seem to be ignored when running yesod devel.

You want to use the -p option. More generally:
$ yesod devel --help
Usage: yesod devel [-d|--disable-api] [-s|--success-hook COMMAND]
[-f|--failure-hook COMMAND] [-t|--event-timeout N]
[-b|--builddir ARG] [-i|--ignore DIR]
[-e|--extra-cabal-arg ARG] [-p|--port N]
[-x|--proxy-timeout N] [-n|--disable-reverse-proxy]
[-c|--interrupt-only]
Run project with the devel server
Available options:
-d,--disable-api Disable fast GHC API rebuilding
-s,--success-hook COMMAND
Run COMMAND after rebuild succeeds
-f,--failure-hook COMMAND
Run COMMAND when rebuild fails
-t,--event-timeout N Force rescan of files every N seconds
-b,--builddir ARG Set custom cabal build directory, default `dist'
-i,--ignore DIR ignore file changes in DIR
-e,--extra-cabal-arg ARG pass extra argument ARG to cabal
-p,--port N Devel server listening port
-x,--proxy-timeout N Devel server timeout before returning 'not ready'
message (in seconds, 0 for none)
-n,--disable-reverse-proxy
Disable reverse proxy
-c,--interrupt-only Disable exiting when enter is pressed

Related

Clojure 1.9 command line tools - command not found clj.sh

I have just installed clojure 1.9 on my mac via Homebrew.
As expected I get 2 links in /usr/local/bin to the actual executables
clojure# -> ../Cellar/clojure/1.9.0.358/bin/clojure
clj# -> ../Cellar/clojure/1.9.0.358/bin/clj
running clojure from the command line works
$ clojure
Clojure 1.9.0
user=>
but for not for the command line tools
$ clj
zsh: command not found: clj.sh
both executable files exist
$ ls Cellar/clojure/1.9.0.358/bin
clj* clojure*
I've tried uninstalling clojure with brew uninstall and have deleted the cached version of clojure-tools-1.9.0.358.tar.gz in my ~/Library/Caches/Homebrew/ directory.
Installing it again was successful
$ brew install clojure
==> Downloading https://download.clojure.org/install/clojure-tools-1.9.0.358.tar.gz ####### 100.0%
==> ./install.sh /usr/local/Cellar/clojure/1.9.0.358
đŸș /usr/local/Cellar/clojure/1.9.0.358: 9 files, 19.4MB, built in 31 seconds
but still the same error.
Interestingly if I use the Finder to locate the file and double click on it, a new terminal window opens up and things seem to work.
Last login: Tue Mar 6 10:35:48 on ttys002
/usr/local/Cellar/clojure/1.9.0.358/bin/clj ; exit;
$ /usr/local/Cellar/clojure/1.9.0.358/bin/clj ; exit;
Clojure 1.9.0
user=>
Any ideas please on why this executable won't run directly from the command line?
Many thanks
The problem was that I'd set up an alias for clj in my shell profile file which referenced a shell script called clj.sh that I'd written but which no longer exists - hence why nothing happened except an error message.
Removing the alias from the shell profile file corrected the problem.

Nix Gradle dist - Failed to load native library 'libnative-platform.so' for Linux amd64

I am trying to build a Freeplane derivation based on Freemind, see: https://github.com/razvan-panda/nixpkgs/blob/freeplane/pkgs/applications/misc/freeplane/default.nix
{ stdenv, fetchurl, jdk, jre, gradle }:
stdenv.mkDerivation rec {
name = "freeplane-${version}";
version = "1.6.13";
src = fetchurl {
url = "mirror://sourceforge/project/freeplane/freeplane%20stable/freeplane_src-${version}.tar.gz";
sha256 = "0aabn6lqh2fdgdnfjg3j1rjq0bn4d1947l6ar2fycpj3jy9g3ccp";
};
buildInputs = [ jdk gradle ];
buildPhase = "gradle dist";
installPhase = ''
mkdir -p $out/{bin,nix-support}
cp -r ../bin/dist $out/nix-support
sed -i 's/which/type -p/' $out/nix-support/dist/freeplane.sh
cat >$out/bin/freeplane <<EOF
#! /bin/sh
JAVA_HOME=${jre} $out/nix-support/dist/freeplane.sh
EOF
chmod +x $out/{bin/freeplane,nix-support/dist/freeplane.sh}
'';
meta = with stdenv.lib; {
description = "Mind-mapping software";
homepage = https://www.freeplane.org/wiki/index.php/Home;
license = licenses.gpl2Plus;
platforms = platforms.linux;
};
}
During the gradle build step it is throwing the following error:
building path(s)
‘/nix/store/9dc1x2aya5p8xj4lq9jl0xjnf08n7g6l-freeplane-1.6.13’
unpacking sources unpacking source archive
/nix/store/c0j5hgpfs0agh3xdnpx4qjy82aqkiidv-freeplane_src-1.6.13.tar.gz
source root is freeplane-1.6.13 setting SOURCE_DATE_EPOCH to timestamp
1517769626 of file freeplane-1.6.13/gitinfo.txt patching sources
configuring no configure script, doing nothing building
FAILURE: Build failed with an exception.
What went wrong: Failed to load native library 'libnative-platform.so' for Linux amd64.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. builder for ‘/nix/store/id4vfk3r6fd4zpyb15dq9xfghf342qaa-freeplane-1.6.13.drv’
failed with exit code 1 error: build of
‘/nix/store/id4vfk3r6fd4zpyb15dq9xfghf342qaa-freeplane-1.6.13.drv’
failed
Running gradle dist from terminal works fine. I'm guessing that maybe one of the globally installed Nix packages provides a fix to the issue and they are not visible during the build.
I searched a lot but couldn't find any working solution. For example, removing the ~/.gradle folders didn't help.
Update
To reproduce the issue just git clone https://github.com/razvan-panda/nixpkgs, checkout the freeplane branch and run nix-build -A freeplane in the root of the repository.
Link to GitHub issue
Maybe you just don't have permission for the folder/file
sudo chmod 777 yourFolderPath
you can also : sudo chmod 777 yourFolderPath/* (All folder)
Folder will not be lockedthen You can use it normally
[At least I succeeded。。。]
EX:
sudo chmod 777 Ruby/
now ,that's ok
To fix this error: What went wrong: Failed to load native library 'libnative-platform.so' for Linux amd64. do the following:
Check if your Gradle cache (**~user/.gradle/**native folder exist at all or not).
Check if your Gradle cache (~user/.gradle/native folder exist and the file in question i.e. libnative-platform.so exists in that directory or not).
Check if the above folder ~user/.gradle or ~/.gradle/native or file: ~/.gradle/native/libnative-platform.so has valid permissions (should not be read-only. Running chmod -R 755 ~/.gradle is enough).
IF you don't see native folder at all or if your native folder seems corrupted, run your Gradle task ex: gradle clean build using -g or --gradle-user-home option and pass it's value.
Ex: If I ran mkdir /tmp/newG_H_Folder; gradle clean build -g /tmp/newG_H_Folder, you'll see Gradle will populate all the required folder/files (that it needs to run even before running any task or any option) are now in this new Gradle Home folder (i.e. /tmp/newG_H_Folder/.gradle directory).
From this folder, you can copy - just the native folder to your user's ~/.gradle folder (take backup of existing native folder in ~/.gradle first if you want to) if it already exists -or copy the whole .gradle folder to your ~ (home directory).
Then rerun your Gradle task and it won't error out anymore.
Gradle docs says:
https://docs.gradle.org/current/userguide/command_line_interface.html
-g, --gradle-user-home
Specifies the Gradle user home directory. The default is the .gradle directory in the user’s home directory.

Git Bash for Windows not working 'lein repl' command

I'm actually using git bash instead of default windows command shell (cmd).But I cannot run 'lein repl' in git bash. It doesn't show anything and I must press crtl + c to regain control.
Any suggestion?
Thank you.
-- EDIT
I'm running lein instead of lein.bat because I added alias lein=lein.bat in my .bashrc, so I don't think it is a problem.
lein run is working fine in Git Bash and leiningen works fine in windows cmd. The problem is explicity with lein repl.
When I run which lein I got which: no lein in ([MY-PATH-VAR])
First Check if you have installed lein.bat in windows using below command in command prompt
lein --version
Then if lein is available, then in your git bash type the below command
alias lein='lein.bat'
Thein run your lein command it will work for sure...
I had exactly the same problem as ThomasH where calling lein repl from an Emacs shell would get me the introductory messages and a prompt ...
nREPL server started on port 55801 on host 127.0.0.1 - nrepl://127.0.0.1:55801
REPL-y 0.4.4, nREPL 0.8.3
Clojure 1.10.1
Java HotSpot(TM) 64-Bit Server VM 15.0.2+7-27
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
... but seemingly freeze when I try to get it to do anything, like:
user=> (+ 1 2 3 8)
When I open up the Task Manager, I could see the underlying Java program continuously at ~30% CPU for no apparent reason, and the only way I could reliably get out of it was to end the Java process from there.
But through a lot of effort, I finally figured out that the reason this was happening was a shell environment variable TERM=emacs. Whenever you call M-x shell, the function comint-term-environment puts it in for you.
(According to the source code in comint.el, it's done so that it "lets us specify a width". And it also mentions that "Some programs that use terminfo get very confused if TERM is not a valid terminal type". So there you have it - it looks like Java is one of those.)
To resolve this, you can set the variable system-uses-terminfo to 't before calling M-x shell.
(setq system-uses-terminfo t)
After having done so, Java is now finally responsive and I can evaluate things in the repl.
user=> (+ 1 2 3 8)
14
If you have this problem and got fortunate enough to stumble here, I hope this helps! =D
The following worked for me to get this running in Git bash on Windows 10. When I originally got this working, it was freezing, but this post helped me figure out how to fix by including winpty.
If you haven't added the lein.bat file to your Path variable, then do steps 1-3. Otherwise, skip to 4. In the System Properties -> Advanced -> Environment Variables area, select the Path variable
Click Edit and add the directory containing lein.bat to this. Mine was C:\Program Files (x86)\lein - lein.bat was stored inside the lein folder
Click OK until you close out of the prompts
Confirm the update worked by opening a command prompt (windows key, then type cmd)
Enter lein. If you haven't already, it should prompt you to run the install command. Do this if prompted, then enter lein again to make sure it worked (should output help menu)
Close out of Git bash if already open, then open again
Enter alias repl='winpty lein.bat repl'. You can choose what you want the alias to be, I used repl
Type repl (or whatever alias you added). Should take a second, then begin a REPL prompt
Using GitBash as your terminal, you can install the lein script rather than the lein.bat script.
The lein script will run correctly in GitBash (as it is effectively a Unix environment).
I recommend installing the lein script in a directory called bin in your user account directory, e.g.:
c:/Users/your-account/bin
Placing the lein script in bin will allow you to run the lein command anywhere on the GitBash command line.
A Note about Emacs, lein and windows
The lein script will also be called correctly from Emacs, assuming you run Emacs from the GitBash terminal, ie. runemacs. Add Emacs install directory to your user account PATH environment variable and GitBash will find it on the command line.
Emacs installed on Windows works better when run from the GitBash terminal, as you can then use ediff in Emacs, which requires the diff command that GitBash terminal provides.
My recommended Emacs installs for windows
zklhp emacs-w64 optomised
Chocolatey Emacs 64bit
My experience was that lein repl (and I do use the lein bash script) would start up ok, also printing the startup messages of the lein command to the shell, but would then stop to output anything (although the process might be running fine), part. not providing an interactive prompt (except for the first), not echoing user input (except for the first), nor printing evaluation results. When terminating the process with Ctrl-C all my inputs would be passed to the underlying shell (with funny results like $ (+ 3 4) bash: +: command not found).
My solution is to use Git CMD for interactive commands like lein repl, lein figwheel etc., which (unfortunately, as it might seem) works fine. Running a Git sh process inside a different terminal emulation (Cmder) also gives me a working interactive environment.

Running the "exec" command in Jenkins "Execute Shell"

I'm running Jenkins on a Linux host. I'm automating the build of a C++ application. In order to build the application I need to use the 4.7 version of g++ which includes support for c++11. In order to use this version of g++ I run the following command at a command prompt:
exec /usr/bin/scl enable devtoolset-1.1 bash
So I created a "Execute shell" build step and put the following commands, which properly builds the C++ application on the command prompt:
exec /usr/bin/scl enable devtoolset-1.1 bash
libtoolize
autoreconf --force --install
./configure --prefix=/home/tomcat/.jenkins/workspace/project
make
make install
cd procs
./makem.sh /home/tomcat/.jenkins/workspace/project
The problem is that Jenkins will not run any of the commands after the "exec /usr/bin/scl enable devtoolset-1.1 bash" command, but instead just runs the "exec" command, terminates and marks the build as successful.
Any ideas on how I can re-structure the above so that Jenkins will run all the commands?
Thanks!
At the begining of your "Execute shell" script, execute source /opt/rh/devtoolset-1.1/enable to enable the devtoolet "inside" of your shell.
Which gives:
source /opt/rh/devtoolset-1.1/enable
libtoolize
autoreconf --force --install
./configure --prefix=/home/tomcat/.jenkins/workspace/project
make
make install
cd procs
./makem.sh /home/tomcat/.jenkins/workspace/project
I needed to look up what scl actually does.
Examples
scl enable example 'less --version'
runs command 'less --version' in the environment with collection 'example' enabled
scl enable foo bar bash
runs bash instance with foo and bar Software Collections enabled
So what you are doing is running a bash shell. I guess, that the bash shell returns immediately, since you are in non-interactive mode. exec runs the the command within the shell without creating a new shell. That means if the newly opened bash ends it also ends your shell prematurely. I would suggest to put all your build steps into a bash script (e.g. run_my_build.sh) and call it in the following way.
exec /usr/bin/scl enable devtoolset-1.1 run_my_build.sh
This kind of thing normally works in "find" commands, but may work here. Rather than running two, or three processes, you run one "sh" that executes multiple things, like this:
exec sh -c "thing1; thing2; thing3"
If you require each step to succeed before the next step, replace the semi-colons with double ampersands:
exec sh -c "thing1 && thing2 && thing3"
I have no idea which of your steps you wish to run together, so I am hoping you can adapt the concept to fit your needs.
Or you can put the whole lot into a script and exec that.

ClojureScript bRepl does not respond at all

I've been tinkering with clojure and clojurescript for some time and I always found the browser repl to be extremely unresponsive. It usually hangs on without giving a result, or throws a broken pipe exception. Now I'm in a situation where it always refuses to work.
Let's say I download the modern-cljs tutorial part 2 and I do all the steps to start the page, load the compiled javascript and start the bRepl. When I try to evaluate something as simple as (+ 3 4) well, it just doesn't work.
I'm on OSX 10.8.4 and my leiningen version is 2.3.2 on Java 1.6.0_51 Java HotSpot(TM) 64-Bit Server VM. Any help is extremely appreciated.
I would suggest to clone the modern-cljs repo, then checkout the tutorial-02 branch, then clean and recompile.
git clone https://github.com/magomimmo/modern-cljs.git
cd modern-cljs
git checkout tutorial-02
lein do clean, cljsbuild clean
lein cljsbuild once
Be sure to have your http-server running (I'm assuming the port is 3000) and its root set to modern-cljs/resources/public directory
Then run the repl-listen substask as follows:
lein trampoline cljsbuild repl-listen
Wait for the cljs prompt. Then visit the localhost:3000/simple.html URL and wait that the connection with the brepl is ready.
At the cljs prompt you should now be able to evaluate cljs expressions. Eventually, reload the above URL.
If it still does not work, try to delete your maven repository:
rm -rf ~/.m2/repository
and redo everything from the lein do chain of commands.
Eventually you can follow the https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-18.md#the-need-of-a-more-comfortable-brepl-experience tutorial to set up a more comfortable bREPL which uses https://github.com/cemerick/piggieback
HIH
I've had a few problems with this topic too. And here are the tricks that help me:
Clean leain deps: rm -rf ~/.m2/*
download lein deps: lein deps in your project root
I saw this message: "broken pipe" when there was too much time from the last brepl interaction. So, refresh the browser and that's all
sometimes my brepl hung on the first time i was trying to evaluate the code, again try to refresh the browser
don't forget to run: lein cljsbuild once before start the brepl
Good luck
PS: Anyway if you want to have a comfortable brepl experience you have to take a look to https://github.com/cemerick/austin . I have tested this brepl and works fine https://github.com/juanantonioruz/client
You should try using Chromium unsafely:
OS X:
open -a Chromium --args --disable-web-security
Linux:
chromium --disable-web-security
Then visit your page in the unsafe browser and try to connect to the brepl.
Explanation:
Because while brepl is running on port 9000, the web server hosting the page is necessarily using a different port, which constitutes XSS (see [this stack overflow discussion]).
The easiest way to get around this is to use Chromium unsafely for debugging, but you can enable XSS by some other means if you want.
What ClojureScript release are you specifying in your project.clj? If you aren't specifying a specific release, this likely the source of your troubles. 0.0-1913 is the latest one.
I've also seen a complete hang in the REPL when I forget to call repl/connect from within the browser. Since there is no output, it's hard to diagnose. It's worth verifying before you try more intrusive remedies.