Specify a clang-format file kept in $HOME - clang-format

I can use clang-format using the following command-
clang-format -style=file main.cpp
Please note that the .clang-format file is kept at the project directory.
Is there any way to keep .clang-format file in $HOME?

Before installing clang-fomat on my machine there wasn't a .clang-format file. After installing via homebrew:
brew install clang-format
checked again, and I found an empty clang-format file in my HOME directory.
If your clang-format application is already installed, you can place your clang-format file at your HOME directory. That will effect all project which hasn't own a ".clang-format" file.
Best

Related

Homebrew - installed elsewhere and can't run it

I have incorrectly installed Homebrew to a different folder and now can't interact with it nor uninstall it. It is located in: users/pavel/learningpython/homebrew
Is there a safe way to uninstall it all or reconfigure it so I can run it?
Thank you
I tried to change directory to various folders, be it those under the homebrew folder or outside of it, but can't seem to run homebrew anywhere. At first, when I was not able to even locate it, I tried various solutions with the .zshr file and it was not helpful. So I see Homebrew in Mac Finder, but can't find a way to interact with it, it always says "brew not found".
This is what the brew executable file writes when I run it through Finder:
/Users/pavel/learningpython/homebrew/bin/brew ; exit;
/Users/pavel/.zprofile:6: no such file or directory: /opt/homebrew/bin/brew
/Users/pavel/.zprofile:7: no such file or directory: /opt/homebrew/bin/brew

Permission denied on running globally activated dart package

I'm trying to develop a command line package so I followed these steps:
dart create --template=package-simple package_name
then activating the package globally with:
dart pub global activate --source path $(pwd)
note that I didn't find anything in the documentation about --source path actual_path but whenever I use the command only with --source actual_path I get the following:
"/Users/user/Desktop/Workspace/package_name" is not an allowed value for option "source".
So after successfully activating the package I tried to run it using:
package_name
But I got this:
zsh: command not found: package_name
Found out that the documentation here is outdated and after searching the local directory I found the actual directory is global_packages not bin, and so I've changed it.
Now when I try package_name I get:
zsh: permission denied: package_name
After investigation I found that package_name is a directory in the global_packages directory and it only contains pubspec.lock so I've tried chmod a+x on the file and the directory with no avail.
Further investigation the global_packages contained another package intl_utils inside I found:
.packages incremental
.dart_tool bin pubspec.lock
But running intl_utils on the terminal too get's me the same error:
zsh: permission denied: intl_utils
I didn't install the package manually but the VS Code extension Flutter Intl did and it seems to work perfectly fine.
Now I have two questions:
permission denied on what exactly since the Flutter Intl extension works perfectly???
I have a file in my package bin/my_package.dart but it didn't go there, am I doing something wrong?
I'm running dart through flutter:
Flutter (Channel master, 2.13.0-0.0.pre.90, on macOS 12.3 21E230 darwin-x64, locale en-US)
dart --version
Dart SDK version: 2.17.0-202.0.dev (dev) (Thu Mar 10 20:55:41 2022 -0800) on "macos_x64"
Edit #1
Tried dart pub global run package_name and it worked but it seems like it's building the package again, but still I need to use it without the long line the correct way.
Edit #2
To create the app I've tried
dart create -t console-full package_name but still with the same results.
So after messing around and changing the branch (a lot) turns out the problem is in the pubspec.yaml where there should be :
executables:
package_name: # you can add a custom path here if you want though
And I guess the docs were right about "bin" directory but it left me wondering about global_packages and intl_utils

How do I install clang-format without root privileges and without installing LLVM?

I have clang-format version 3.8.0 (tags/RELEASE_380/final) in my ~/bin folder on a Fedora machine with no root privileges. It works, but it is very old and I'd like to upgrade. I just want the clang-format tool, so I would like to avoid going through the full installation process for LLVM or clang if I can avoid it. I assume I can avoid it, since my old clang-format works without either of those installed. I don't remember how clang-format got in my ~/bin directory, and I can't figure out how to update it.
The first thing I tried was following this post which said I should be able to download a prebuilt binary from this page (I tried http://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-linux-gnu-Fedora27.tar.xz), then just set up a symlink to bin/clang-format. This did not work for me. When I type /path/to/bin/clang-format --help I get the error error while loading shared libraries: libtinfo.so.6: cannot open shared object file: No such file or directory.
The next thing I tried is downloading the clang source code and compiling that with
mkdir build && cd build && CC=$(which gcc) CXX=$(which g++) cmake ..
but when I did I got the error
CMake Error at CMakeLists.txt:36 (message):
llvm-config not found -- LLVM_CONFIG-NOTFOUND
Which I guess means I'd need to install the LLVM to go this route?
Any help getting an updated clang-format (vesion 5.0 at minimum) without root access would be appreciated. Bonus points for minimal installation (i.e. no clang or llvm).
=== EDIT ===
By downloading a bunch of different versions of prebuilt binaries, I've discovered that older versions (<4.0) have clang-formats that work out of the box, but at 4.0 and up give the same error about libtinfo. I guess that means I'll have to live with older versions unless I want to go through a painful installation process.
When you download llvm 6.0, make sure the directory structure is as follows:
llvm
|-->tools
|----->clang
|----> tools
|----> extra
If you just want to build clang-format, then you can cd into
llvm-build-dir/tools/clang/tools/extra/clang-format and then execute make -j8 all
later you can make a symbolic link in your /bin folder

Installing Chisel

I'm trying to install Chisel.
I ran the following commands in command line.
brew update
brew install chisel
the final step is to follow the instructions that Homebrew displays to add chisel to your ~/.lldbinit.
I cannot find .lldbinit file. Any ideas?
I figured it out. Simply create .lldbinit in your home directory. I used sublime and added the following text to the file.
# ~/.lldbinit
...
command script import /path/to/fblldb.py
make sure you update the 'path' portion with your actual path. This can be obtained from command line when you do 'brew install chisel'
Save, restart Xcode. Done!
.lldbinit file is not required for lldb to work so it is not created by default. If you don't have it already just create new empty file and add all necessary lines to it.

Brew doctor gives out warnings

when I ran brew doctor I go loads of warnings. So I went ahead, cleaned out the existing installation and did it from scratch.
Now I still get some warnings:
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/opt/sm/pkg/active/bin/curl-config
/opt/sm/pkg/active/bin/ncurses5-config
/opt/sm/pkg/active/bin/ncursesw5-config
/opt/sm/pkg/active/bin/pkg-config
/opt/sm/pkg/active/bin/xml2-config
/opt/sm/pkg/active/bin/xslt-config
Warning: You have a non-Homebrew 'pkg-config' in your PATH:
/opt/sm/pkg/active/bin/pkg-config
`./configure` may have problems finding brew-installed packages using
this other pkg-config.
But since I only started using OS X a few days ago, I am not sure if the mentioned config files are relevant or if I can just delete them? Have already been looking through forums for hours, but still none the wiser at the moment... Any advice is very much appreciated!
Try taking /opt/sm/pkg/active/bin/ out of your PATH.
That will prevent the scripts installed in that directory from accidentally taking precedence over the ones installed by homebrew.
If you're a newbie like me and want a more clear answer on exactly how to do this, I found this answer here How to change path for homebrew: "config" scripts exist outside your system or Homebrew directories and it worked for me:
The /opt/sm is in the /etc/profile.d directory. Open it by entering
cd /etc/profile.d
in terminal and then
open .
Open sm.sh file in text editor and then comment out the path by putting a hash sign # in front of
PATH="${PATH}:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin"
Save the change in your text editor and then quit and relaunch Terminal. Run brew doctor 'Warning' should be gone.

Resources