Double clicking Unix Executable file is different from running it from terminal - macos

I'm trying to create .app package that contains jdk, jar and shell script, basically I'm trying to run jar inside .app.
My contents inside .app looks like this (app has same name as unix executable):
.
├── MacOS
│   └── AppName
├── app
│   └── myapp.jar
└── jdk
AppName, if we give it .sh extension and look into it, looks like this
#!/bin/zsh
../jdk/bin/java -jar ../app/myapp.jar
If I run this file executable file from terminal with ./AppName it works without any problems. But if I just double click it, it doesn't work saying no such file or directory: ../jdk/bin/java.
I believe it should work with double clicking in order to work with .app, because other .app-s work like this.

Relative path names like ../jdk/bin/java are relative to the current working directory, not to the location of the script.
You can reproduce the problem in the terminal when your working directory is not MacOS but, e.g., the parent directory, and you start the application as MacOS/AppName.
A possible solution might be
#!/bin/zsh
SCRIPTDIR=$(dirname $0)
"$SCRIPTDIR"/../jdk/bin/java -jar "$SCRIPTDIR"/../app/myapp.jar

Related

Yarn 2 : how to run a script from the `node_modules/.bin` directory?

How can I run a script from the node_modules/.bin directory with Yarn 2 ?
Example
Suppose I need to run an "eslint" script located in that directory
node_modules
├── .bin
│ ├── eslint
With NPM, I can just run npx eslint to run the excutable. How can I achieve this with Yarn 2 ?
It is same as what it used to be in classic Yarn, run this:
yarn eslint
Refer: https://yarnpkg.com/cli/run#details
This command will run a tool. The exact tool that will be executed will depend on the current state of your workspace:
If the scripts field from your local package.json contains a matching script name, its definition will get executed.
Otherwise, if one of the local workspace's dependencies exposes a binary with a matching name, this binary will get executed.
Otherwise, if the specified name contains a colon character and if one of the workspaces in the project contains exactly one script with a matching name, then this script will get executed.
If you want to ignore any user defined scripts and only check for binaries, you can pass -B option.
There is also yarn exec:
yarn exec eslint

VSCode terminal settings

There is a directory structure something like given below-
Demo/
└── Project
└── sample.py
I opened Project/ directory in the VS Code but the path shown in the terminal is from its root directory i.e., shubhanshusingh#shubhanshusingh:~/Demo/Project$ that I don't want.
I want it to be like this shubhanshusingh#shubhanshusingh:~/Project$, that is, show only the name of the last directory. Is there any configuration that I can set for the VS Code terminal? Please let me know.
I am using WSL:Ubuntu

Deploying Go App with Heroku

I'm using this guide to build a small Go app:
https://codegangsta.gitbooks.io/building-web-apps-with-go/index.html
Folder structure looks like this:
go/src/fileserver/
main.go
fileserver.exe
public/
index.html
css/
bootstrap.min.css
The deployment instructions mention a "procfile" and a ".godir" file but it's a bit unclear what these are supposed to contain or where they are to be implemented. I'm not quite sure if my folder structure is correct either.
The error I'm getting is:
Failed to detect set buildpack https://github.com/kr/heroku-buildpack-go.git
Am going to be quoting the heroku documentation a lot.
Procfile
Define a Procfile
Use a Procfile, a text file in the root directory of your application, to explicitly declare what command should be executed to start your app.
The Procfile in the example app you deployed looks like this:
web: go-getting-started
This declares a single process type, web, and the command needed to run it. The name web is important here. It declares that this process type will be attached to the HTTP routing stack of Heroku, and receive web traffic when deployed. The command used here, go-getting-started is the compiled binary of the getting started app.
Procfiles can contain additional process types. For example, you might declare one for a background worker process that processes items off of a queue.
Define a Procfile
So in your example you would have a file named 'Procfile' in your root directory with contents being:
web: fileserver
.godir
The .godir file is simply a file that simply specifies the root directory of your go project. This is useful when you say have a number of modules for a web app in different languages. So for example given a repo with the following tree.
github.com
└──someuser
└── somerepo
├── .godir
├── go_module
└── node_module
Where the contents of your .godir file would be:
github.com/someuser/somerepo/go_module
A more verbose explanation of what .godir is for and when it is used can be found here.

How does cocoapods multiple private repo using a same repo.git

I have several private repo,such as A,B,C,D and the remote git url is https://127.0.0.1/repo/repo.git . How can i push A,B,C,D to the same remote git url(https://127.0.0.1/repo/repo.git) ? then local git just like .cocoapods/repos/master/Specs content, such as
├── Specs
└── A
└── B
└── C
└── D
if it done , how can i make the profile for installing.
Just add the pod-spec file of your cocoa-pod to the main repo folder and update the pod-spec source files path.
More details:
to create a cocoa-pod you need two steps
pod lib create POD_NAME
///this command runs in terminal to create for you a library with example option and many other things
pod lib lint POD_NAME.podspec
/// validate your spec file, check syntax and your files.
You could skip the first command and create your pod-spec file manually || copy it from any repo
then update it, add your code to your cocoa-pod folder, set the git repo in your pod-spec
make sure the git-repo have the pod-spec file in the main directory
You will find a complete example with Demo application in this project
https://github.com/abuzeid-ibrahim/DevPods

How to configure haxe build file (HXML) to build from src directory?

I'm trying to build a pre-existing HaxePunk project in sublime (switching away from FlashDevelop).
problem: Error: Could not process argument
Here's my .hxml file:
-neko
-cp "c:/path/to/project/src"
-main Main
I've read somewhere that you shouldn't use the /src convention for your src files. That's annoying, since I want assets and binaries in their own directories separate from src files. How do I properly configure this?
You really should use the the src convention and not stuff everything within the same directory. You also don't want to make the build specific to your machine, so in you example above you don't want an absolute path but a relative one. So try the following:
#content of c:/path/to/project/build.hxml
-neko bin/output.n
-cp src
-main Main
Note that for -cp you use the relative path. The path is relative to where haxe is executed. That usually coincides with where your build.hxml file is, but it is not mandatory.
Also, you didn't specify an output file for neko. Note that you will have to create the directory bin by hand because the compiler will not do that for you and will complain if it doesn't exist.
These information are general and in no way tied with Sublime. Sublime should play just nice with these settings.

Resources