Giter Site home page Giter Site logo

Comments (12)

fourniej03 avatar fourniej03 commented on August 22, 2024 5

You can work around this by running calling bash instead of sh on Ubuntu:

bash -c 'source ./scripts/source-me.sh  && ./scripts/go-compile.sh ./vault-web-server'

adjust the setting in package.json for both the start and install parameters.

from vault-ai.

eabjab avatar eabjab commented on August 22, 2024 4

Probably not the "best" solution, but I got it running locally on Windows by translating source-me.sh and go-compile.sh to PowerShell scripts and using PowerShell dot source syntax to run them. Happy to share if you're interested.

I'd be interested 😊

Here you go! Change the "scripts" property in package.json to:

"scripts": {
    "start": "powershell -Command \". .\\scripts\\source-me.ps1; .\\scripts\\go-compile.ps1 .\\vault-web-server; Write-Host \\\"\\\"; .\\bin\\vault-web-server\"",
    "dev": "webpack --progress --watch",
    "postinstall": "powershell -ExecutionPolicy Bypass -File .\\scripts\\npm-postinstall.ps1"
  }

Then create three new files, all in the scripts directory
"source-me.ps1"

# source-me.ps1
# Useful variables. Source from the root of the project

# Shockingly hard to get the sourced script's directory in a portable way
$script_name = $MyInvocation.MyCommand.Path
$dir_path = Split-Path -Parent $script_name
$secrets_path = Join-Path $dir_path "..\secret"
if (!(Test-Path $secrets_path)) {
    Write-Host "ERR: ..\secret dir missing!"
    return 1
}

$env:GO111MODULE = "on"
$env:GOBIN = Join-Path $PWD "bin"
$env:GOPATH = Join-Path $env:USERPROFILE "go"
$env:PATH = "$env:PATH;$env:GOBIN;$PWD\tools\protoc-3.6.1\bin"
$env:DOCKER_BUILDKIT = "1"
$env:OPENAI_API_KEY = Get-Content (Join-Path $secrets_path "openai_api_key")
$env:PINECONE_API_KEY = Get-Content (Join-Path $secrets_path "pinecone_api_key")
$env:PINECONE_API_ENDPOINT = Get-Content (Join-Path $secrets_path "pinecone_api_endpoint")

Write-Host "=> Environment Variables Loaded"

"go-compile.ps1"

# go-compile.ps1

function pretty_echo {
    Write-Host -NoNewline -ForegroundColor Magenta "-> "
    Write-Host $args[0]
}

# What to compile...
$TARGET = $args[0]
if ([string]::IsNullOrEmpty($TARGET)) {
    Write-Host " Usage: $($MyInvocation.InvocationName) <go package name>"
    exit 1
}

# Install direct code dependencies
pretty_echo "Installing '$TARGET' dependencies"

go get -v $TARGET
$RESULT = $LASTEXITCODE
if ($RESULT -ne 0) {
    Write-Host "   ... error"
    exit $RESULT
}

# Compile / Install the server
pretty_echo " Compiling '$TARGET'"

go install -v $TARGET
$RESULT = $LASTEXITCODE
if ($RESULT -eq 0) {
    Write-Host "   ... done"
    exit 0
} else {
    Write-Host "   ... error"
    exit $RESULT
}

"npm-postinstall.ps1" (I was getting weird errors trying to run the same thing in package.json)

# npm-postinstall.ps1

. .\\scripts\\source-me.ps1
.\\scripts\\go-compile.ps1 .\\vault-web-server

from vault-ai.

eabjab avatar eabjab commented on August 22, 2024 2

Probably not the "best" solution, but I got it running locally on Windows by translating source-me.sh and go-compile.sh to PowerShell scripts and using PowerShell dot source syntax to run them. Happy to share if you're interested.

from vault-ai.

Rohukas avatar Rohukas commented on August 22, 2024 2

Probably not the "best" solution, but I got it running locally on Windows by translating source-me.sh and go-compile.sh to PowerShell scripts and using PowerShell dot source syntax to run them. Happy to share if you're interested.

I'd be interested 😊

Here you go! Change the "scripts" property in package.json to:

"scripts": {
    "start": "powershell -Command \". .\\scripts\\source-me.ps1; .\\scripts\\go-compile.ps1 .\\vault-web-server; Write-Host \\\"\\\"; .\\bin\\vault-web-server\"",
    "dev": "webpack --progress --watch",
    "postinstall": "powershell -ExecutionPolicy Bypass -File .\\scripts\\npm-postinstall.ps1"
  }

Then create three new files, all in the scripts directory "source-me.ps1"

# source-me.ps1
# Useful variables. Source from the root of the project

# Shockingly hard to get the sourced script's directory in a portable way
$script_name = $MyInvocation.MyCommand.Path
$dir_path = Split-Path -Parent $script_name
$secrets_path = Join-Path $dir_path "..\secret"
if (!(Test-Path $secrets_path)) {
    Write-Host "ERR: ..\secret dir missing!"
    return 1
}

$env:GO111MODULE = "on"
$env:GOBIN = Join-Path $PWD "bin"
$env:GOPATH = Join-Path $env:USERPROFILE "go"
$env:PATH = "$env:PATH;$env:GOBIN;$PWD\tools\protoc-3.6.1\bin"
$env:DOCKER_BUILDKIT = "1"
$env:OPENAI_API_KEY = Get-Content (Join-Path $secrets_path "openai_api_key")
$env:PINECONE_API_KEY = Get-Content (Join-Path $secrets_path "pinecone_api_key")
$env:PINECONE_API_ENDPOINT = Get-Content (Join-Path $secrets_path "pinecone_api_endpoint")

Write-Host "=> Environment Variables Loaded"

"go-compile.ps1"

# go-compile.ps1

function pretty_echo {
    Write-Host -NoNewline -ForegroundColor Magenta "-> "
    Write-Host $args[0]
}

# What to compile...
$TARGET = $args[0]
if ([string]::IsNullOrEmpty($TARGET)) {
    Write-Host " Usage: $($MyInvocation.InvocationName) <go package name>"
    exit 1
}

# Install direct code dependencies
pretty_echo "Installing '$TARGET' dependencies"

go get -v $TARGET
$RESULT = $LASTEXITCODE
if ($RESULT -ne 0) {
    Write-Host "   ... error"
    exit $RESULT
}

# Compile / Install the server
pretty_echo " Compiling '$TARGET'"

go install -v $TARGET
$RESULT = $LASTEXITCODE
if ($RESULT -eq 0) {
    Write-Host "   ... done"
    exit 0
} else {
    Write-Host "   ... error"
    exit $RESULT
}

"npm-postinstall.ps1" (I was getting weird errors trying to run the same thing in package.json)

# npm-postinstall.ps1

. .\\scripts\\source-me.ps1
.\\scripts\\go-compile.ps1 .\\vault-web-server

Thanks! Got everything working. 💯

from vault-ai.

Bergdoktor avatar Bergdoktor commented on August 22, 2024 1

You can work around this by running calling bash instead of sh on Ubuntu:

bash -c 'source ./scripts/source-me.sh  && ./scripts/go-compile.sh ./vault-web-server'

adjust the setting in package.json for both the start and install parameters.

I tried your suggestion and replaced the commands in "start" and "postinstall". my package.json now looks like this, is that correct or did i mess up the syntax or quotes?

"scripts": {
    "start": "bash -c 'source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server' && echo && ./bin/vault-web-server",
    "dev": "webpack --progress --watch",
    "postinstall": "bash -c 'source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server'"
  },

After changing the package.json I still encountered another error when running npm start. I'm honestly not sure it is related to calling bash. but maybe you can help me anyway. I try to run the server from Ubuntu but under "Windows Subsystem for linux" (v2).
Thanks in advance!

This is the error log when running npm start:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home>9 verbose lifecycle [email protected]~start: CWD: /home/philipp/vault-ai
10 silly lifecycle [email protected]~start: Args: [ '-c',
10 silly lifecycle   'bash -c \'source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server\' && ech>11 silly lifecycle [email protected]~start: Returned: code: 2  signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `bash -c 'source ./scripts/source-me.sh && ./scripts/go-compil>13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/philipp/vault-ai
16 verbose Linux 5.10.102.1-microsoft-standard-WSL2
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v10.19.0
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 2
22 error [email protected] start: `bash -c 'source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-we>22 error Exit status 2
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]`

from vault-ai.

Rohukas avatar Rohukas commented on August 22, 2024

Probably not the "best" solution, but I got it running locally on Windows by translating source-me.sh and go-compile.sh to PowerShell scripts and using PowerShell dot source syntax to run them. Happy to share if you're interested.

I'd be interested 😊

from vault-ai.

shaiss avatar shaiss commented on August 22, 2024

worked for me, ty!

from vault-ai.

Casboutens avatar Casboutens commented on August 22, 2024

Probably not the "best" solution, but I got it running locally on Windows by translating source-me.sh and go-compile.sh to PowerShell scripts and using PowerShell dot source syntax to run them. Happy to share if you're interested.

I'd be interested 😊

Here you go! Change the "scripts" property in package.json to:

"scripts": {
    "start": "powershell -Command \". .\\scripts\\source-me.ps1; .\\scripts\\go-compile.ps1 .\\vault-web-server; Write-Host \\\"\\\"; .\\bin\\vault-web-server\"",
    "dev": "webpack --progress --watch",
    "postinstall": "powershell -ExecutionPolicy Bypass -File .\\scripts\\npm-postinstall.ps1"
  }

Then create three new files, all in the scripts directory "source-me.ps1"

# source-me.ps1
# Useful variables. Source from the root of the project

# Shockingly hard to get the sourced script's directory in a portable way
$script_name = $MyInvocation.MyCommand.Path
$dir_path = Split-Path -Parent $script_name
$secrets_path = Join-Path $dir_path "..\secret"
if (!(Test-Path $secrets_path)) {
    Write-Host "ERR: ..\secret dir missing!"
    return 1
}

$env:GO111MODULE = "on"
$env:GOBIN = Join-Path $PWD "bin"
$env:GOPATH = Join-Path $env:USERPROFILE "go"
$env:PATH = "$env:PATH;$env:GOBIN;$PWD\tools\protoc-3.6.1\bin"
$env:DOCKER_BUILDKIT = "1"
$env:OPENAI_API_KEY = Get-Content (Join-Path $secrets_path "openai_api_key")
$env:PINECONE_API_KEY = Get-Content (Join-Path $secrets_path "pinecone_api_key")
$env:PINECONE_API_ENDPOINT = Get-Content (Join-Path $secrets_path "pinecone_api_endpoint")

Write-Host "=> Environment Variables Loaded"

"go-compile.ps1"

# go-compile.ps1

function pretty_echo {
    Write-Host -NoNewline -ForegroundColor Magenta "-> "
    Write-Host $args[0]
}

# What to compile...
$TARGET = $args[0]
if ([string]::IsNullOrEmpty($TARGET)) {
    Write-Host " Usage: $($MyInvocation.InvocationName) <go package name>"
    exit 1
}

# Install direct code dependencies
pretty_echo "Installing '$TARGET' dependencies"

go get -v $TARGET
$RESULT = $LASTEXITCODE
if ($RESULT -ne 0) {
    Write-Host "   ... error"
    exit $RESULT
}

# Compile / Install the server
pretty_echo " Compiling '$TARGET'"

go install -v $TARGET
$RESULT = $LASTEXITCODE
if ($RESULT -eq 0) {
    Write-Host "   ... done"
    exit 0
} else {
    Write-Host "   ... error"
    exit $RESULT
}

"npm-postinstall.ps1" (I was getting weird errors trying to run the same thing in package.json)

# npm-postinstall.ps1

. .\\scripts\\source-me.ps1
.\\scripts\\go-compile.ps1 .\\vault-web-server

Tried this and got: The argument '.\scripts\npm-postinstall.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.

double checked that the file is in the secrets folder which it is, and its named correctly and the file has the script in it...

from vault-ai.

mrtt90 avatar mrtt90 commented on August 22, 2024

You can work around this by running calling bash instead of sh on Ubuntu:

bash -c 'source ./scripts/source-me.sh  && ./scripts/go-compile.sh ./vault-web-server'

adjust the setting in package.json for both the start and install parameters.

This resolves that issue, all appears to be running but when I visit public IP or curl localhost testing I get no response... suggestions? I don't get any errors compiling or running the web server. (No firewall, on Ubuntu)
(Also already updated the /vault/ to /vault-ai/ which fixed a number of other errors.

from vault-ai.

Eleksar387 avatar Eleksar387 commented on August 22, 2024

If I try the solution from @fourniej03 I do not get the error as @Bergdoktor (I am also on Win+WSL2) however a npm start results in

> [email protected] start
> bash -c 'source ./scripts/source-me.sh  && ./scripts/go-compile.sh ./vault-web-server'

=> Environment Variables Loaded
-> Installing './vault-web-server' dependencies
->  Compiling './vault-web-server'
   ... done

To my understanding this should start the server and then keep it open. That's why a second terminal has to be opened to run npm dev. If I then do npm run dev I get this:

> [email protected] dev
> webpack --progress --watch

assets by chunk 169 KiB (id hint: vendors)
  asset vendors-node_modules_react-dropzone_dist_es_index_js-node_modules_uuid_dist_esm-browser_v4_js.bundle.js 133 KiB [compared for emit] (id hint: vendors)
  asset vendors-node_modules_react-router-dom_es_Link_js-node_modules_url-parse_index_js-node_modules-b6a711.bundle.js 35.9 KiB [compared for emit] (id hint: vendors)
asset bundle.js 1.18 MiB [compared for emit] (name: app)
asset components_Pages_LandingPage_index_jsx.bundle.js 105 KiB [compared for emit]
asset components_Header_index_jsx.bundle.js 24 KiB [compared for emit]
orphan modules 42 KiB [orphan] 27 modules
runtime modules 6.98 KiB 10 modules
modules by path ./node_modules/ 1.19 MiB 68 modules
modules by path ./components/ 93.9 KiB
  modules by path ./components/*.less 22.8 KiB 6 modules
  modules by path ./components/Util/*.jsx 7.81 KiB 4 modules
  modules by path ./components/Pages/LandingPage/ 20.7 KiB 3 modules
  modules by path ./components/Header/ 8.88 KiB 3 modules
  modules by path ./components/Page/ 6.87 KiB 3 modules
  modules by path ./components/Footer/ 19.2 KiB 3 modules
  modules by path ./components/*.jsx 5.14 KiB
    ./components/index.jsx 430 bytes [built] [code generated]
    ./components/routes.jsx 4.72 KiB [built] [code generated]
  ./components/Go/index.jsx 2.48 KiB [built] [code generated]
webpack 5.64.0 compiled successfully in 2922 ms

There doesn't see, to running any server at http://localhost:8100/ though. I seem to be missing something.

from vault-ai.

mrtt90 avatar mrtt90 commented on August 22, 2024

from vault-ai.

JeffreyBoehme avatar JeffreyBoehme commented on August 22, 2024

Probably not the "best" solution, but I got it running locally on Windows by translating source-me.sh and go-compile.sh to PowerShell scripts and using PowerShell dot source syntax to run them. Happy to share if you're interested.

Worked great for me thankyou man, was scratching my head for hours on this one

from vault-ai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.