GoogleCloudPlatform / functions-framework

The Contract for Building New Function Frameworks
Apache License 2.0
120 stars 12 forks source link

7 Function Framework binaries should have language-specific aliases #38

Closed ace-n closed 3 years ago

ace-n commented 3 years ago

Most of the Functions Frameworks are invoked using either functions-framework or functions_framework terminal commands.

This is fine for environments where only one FF is installed, but environments with multiple FFs (i.e. FFs for multiple languages on the same machine, or multiple FF versions for a single language) make it harder to select specific FFs.

For example:

Node.js directory

$ ls
README.md         all-tests.xml     index.js          node_modules      package-lock.json package.json      test              test.html

Ruby FF (...wait, what?)

$ functions-framework --target=hello_gcs --signature-type=event --port 8089
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /Users/anassri/Desktop in PATH, mode 040776
I, [2020-10-05T18:15:25.641369 #83511]  INFO -- : FunctionsFramework v0.5.1 server starting.
I, [2020-10-05T18:15:25.641410 #83511]  INFO -- : FunctionsFramework: Loading functions from "./app.rb"...
Traceback (most recent call last):
    5: from /usr/local/bin/functions-framework:23:in `<main>'
    4: from /usr/local/bin/functions-framework:23:in `load'
    3: from /Library/Ruby/Gems/2.6.0/gems/functions_framework-0.5.1/bin/functions-framework:19:in `<top (required)>'
    2: from /Library/Ruby/Gems/2.6.0/gems/functions_framework-0.5.1/lib/functions_framework/cli.rb:111:in `run'
    1: from /Library/Ruby/Gems/2.6.0/gems/functions_framework-0.5.1/lib/functions_framework/cli.rb:135:in `start_server'
/Library/Ruby/Gems/2.6.0/gems/functions_framework-0.5.1/lib/functions_framework/cli.rb:135:in `load': cannot load such file -- ./app.rb (LoadError)

One possible fix is to add aliases to the existing FF binaries - e.g. functions-framework-<LANGUAGE>, and maybe functions-framework-<LANGUAGE>-<VERSION>. (N.B: I suspect the former is more common than the latter.)


Note: This is an addition - so functions-framework would still work, but may point to an arbitrary FF binary if run on a machine with multiple FFs installed.

dazuma commented 3 years ago

The latest version (0.7.0) of the Ruby framework provides both functions-framework-ruby and functions_framework, but deprecates the latter. (i.e. it works, but prints a warning suggesting that users use functions-framework-ruby instead.) Additionally, I just finished updating the Ruby GCF buildpack to use functions-framework-ruby instead of functions-framework. That's the behavior I'd recommend in general.

grant commented 3 years ago

@ace-n I think this global functions-framework binaries only happened to very specific languages, i.e. python and ruby. Thus I don't think other languages need specific aliases.

Do you mind filing an issue to not use the generic functions-framework name in language-specific repos as you see the issue? I think that will make more progress.

ace-n commented 3 years ago

Done (for Python and Node - since the Node FF can be installed globally via npm install -g)