pashpashpash / vault-ai

OP Vault ChatGPT: Give ChatGPT long-term memory using the OP Stack (OpenAI + Pinecone Vector Database). Upload your own custom knowledge base files (PDF, txt, epub, etc) using a simple React frontend.
https://vault.pash.city
MIT License
3.26k stars 307 forks source link

Error regarding "source" #7

Open Ivan-Malinovski opened 1 year ago

Ivan-Malinovski commented 1 year ago

I attempted to run vault-ai locally, but I'm getting the following error, both on my Ubuntu and Windows install:

'source' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path C:\Users\user\Documents\vault-ai\vault-ai
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server

I do have NPM 19.2.0 installed and the latest Golang.

I was thinking of making a Dockerfile, but I'm getting the same error when attempted to do that there, regardless of the base image.

eabjab commented 1 year ago

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.

Rohukas commented 1 year ago

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 😊

fourniej03 commented 1 year ago

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.

eabjab commented 1 year ago

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
Rohukas commented 1 year ago

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. 💯

shaiss commented 1 year ago

worked for me, ty!

Casboutens commented 1 year ago

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...

mrtt90 commented 1 year ago

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.

Bergdoktor commented 1 year ago

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 npm@6.14.4
3 info using node@v10.19.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle vault-web-server@1.0.0~prestart: vault-web-server@1.0.0
6 info lifecycle vault-web-server@1.0.0~start: vault-web-server@1.0.0
7 verbose lifecycle vault-web-server@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle vault-web-server@1.0.0~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home>9 verbose lifecycle vault-web-server@1.0.0~start: CWD: /home/philipp/vault-ai
10 silly lifecycle vault-web-server@1.0.0~start: Args: [ '-c',
10 silly lifecycle   'bash -c \'source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server\' && ech>11 silly lifecycle vault-web-server@1.0.0~start: Returned: code: 2  signal: null
12 info lifecycle vault-web-server@1.0.0~start: Failed to exec start script
13 verbose stack Error: vault-web-server@1.0.0 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 vault-web-server@1.0.0
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 vault-web-server@1.0.0 start: `bash -c 'source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-we>22 error Exit status 2
23 error Failed at the vault-web-server@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]`
Eleksar387 commented 1 year ago

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

> vault-web-server@1.0.0 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:

> vault-web-server@1.0.0 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.

mrtt90 commented 1 year ago

Yes, same issue we have., After fixing stuff to make it run, once running 0 errors, 0 errors in logs, just 0 connections coming in working.

On Wed, Apr 19, 2023 at 10:54 AM Eleksar387 @.***> wrote:

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

@.*** 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:

@.*** 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.

— Reply to this email directly, view it on GitHub https://github.com/pashpashpash/vault-ai/issues/7#issuecomment-1515141107, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7I5GBF654FNG3ISTCJJ7DDXCARFPANCNFSM6AAAAAAXC4PKPA . You are receiving this because you commented.Message ID: @.***>

JeffreyBoehme commented 1 year ago

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